public interface Finder<TYPE> extends Cloneable, Serializable
Finder
implementations must be immutable.Modifier and Type | Interface and Description |
---|---|
static interface |
Finder.FilterSortCriterion<TYPE>
An interface that should be implemented by specific
Finder.SortCriterion objects which are capable to implement
by themselves the sorting of objects, by post-processing an existing collection of objects. |
static interface |
Finder.SortCriterion
A tag interface to mark objects which are meaningful sort criteria that can be passed to
sort(it.tidalwave.util.Finder.SortCriterion) . |
static class |
Finder.SortDirection
An enumeration to define the direction of a sort (ascending or descending).
|
Modifier and Type | Method and Description |
---|---|
int |
count()
Performs the search and returns the count of found items.
|
TYPE |
firstResult()
Performs the search and returns only the first found item.
|
Finder<TYPE> |
from(int firstResult)
Tells the
Finder that only a subset of found items will be returned, starting from the given position. |
Finder<TYPE> |
max(int maxResults)
Tells the
Finder that only a maximum number of found items will be returned. |
<AnotherType> |
ofType(Class<AnotherType> type)
Tells the
Finder that the specified type of results is expected. |
TYPE |
result()
Performs the search assuming that it will return a single item and returns it.
|
List<? extends TYPE> |
results()
Performs the search and returns the found items.
|
Finder<TYPE> |
sort(Finder.SortCriterion criterion)
Tells the
Finder that results will be sorted according to the given criterion, in ascending direction. |
Finder<TYPE> |
sort(Finder.SortCriterion criterion,
Finder.SortDirection direction)
Tells the
Finder that results will be sorted according to the given criterion and direction. |
Finder<TYPE> |
withContext(Object context)
Tells the
Finder that results should be created with the given context. |
@Nonnull Finder<TYPE> from(@Nonnegative int firstResult)
Finder
that only a subset of found items will be returned, starting from the given position.firstResult
- the index of the first result to returnFinder
@Nonnull Finder<TYPE> max(@Nonnegative int maxResults)
Finder
that only a maximum number of found items will be returned.maxResults
- the max number of results to returnFinder
@Nonnull Finder<TYPE> withContext(@Nonnull Object context)
Finder
that results should be created with the given context. This method can be called
multiple times; contexts are accumulated.context
- the contextFinder
@Nonnull <AnotherType> Finder<AnotherType> ofType(@Nonnull Class<AnotherType> type)
Finder
that the specified type of results is expected.type
- the expected type of resultsFinder
@Nonnull Finder<TYPE> sort(@Nonnull Finder.SortCriterion criterion)
Finder
that results will be sorted according to the given criterion, in ascending direction.criterion
- the sort criterionFinder
@Nonnull Finder<TYPE> sort(@Nonnull Finder.SortCriterion criterion, @Nonnull Finder.SortDirection direction)
Finder
that results will be sorted according to the given criterion and direction.criterion
- the sort criteriondirection
- the sort directionFinder
@Nonnull TYPE result() throws NotFoundException, RuntimeException
NotFoundException
- if the search didn't find anythingRuntimeException
- if the search returned more than one single item@Nonnull TYPE firstResult() throws NotFoundException
NotFoundException
- if the search didn't find anything@Nonnull List<? extends TYPE> results()
@Nonnegative int count()
Copyright © 2009–2015 Tidalwave s.a.s. (http://tidalwave.it). All rights reserved.