|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectit.tidalwave.util.spi.FinderSupport<Type,ExtendedFinder>
public abstract class FinderSupport<Type,ExtendedFinder extends Finder<Type>>
A support class for implementing a Finder
. Subclasses only need to implement the computeResults()
method where raw results are retrieved (with raw we mean that they shouldn't be filtered or sorted, as
post-processing will be performed by this class) and a clone constructor.
If you don't need to extend the Finder
with extra methods, please use the simplified
SimpleFinderSupport
.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface it.tidalwave.util.Finder |
---|
Finder.FilterSortCriterion<Type>, Finder.SortCriterion, Finder.SortDirection |
Field Summary | |
---|---|
protected int |
firstResult
|
protected int |
maxResults
|
protected java.util.List<it.tidalwave.util.spi.FinderSupport.Sorter<Type>> |
sorters
|
Constructor Summary | |
---|---|
protected |
FinderSupport()
|
protected |
FinderSupport(java.lang.String name)
Creates an instance with the given name (that will be used for diagnostics). |
Method Summary | ||
---|---|---|
FinderSupport<Type,ExtendedFinder> |
clone()
Clones this object. |
|
protected java.util.List<? extends Type> |
computeNeededResults()
Subclasses can implement this method where *only the requested* raw results must be retrieved. |
|
protected java.util.List<? extends Type> |
computeResults()
Subclasses can implement this method where *all* the raw results must be actually retrieved. |
|
int |
count()
Performs the search and returns the count of found items. |
|
Type |
firstResult()
Performs the search and returns only the first found item. |
|
ExtendedFinder |
from(int firstResult)
Tells the Finder that only a subset of found items will be returned, starting from the given position. |
|
ExtendedFinder |
max(int maxResults)
Tells the Finder that only a maximum number of found items will be returned. |
|
|
ofType(java.lang.Class<AnotherType> type)
|
|
Type |
result()
Performs the search assuming that it will return a single item and returns it. |
|
java.util.List<? extends Type> |
results()
Performs the search and returns the found items. |
|
ExtendedFinder |
sort(Finder.SortCriterion criterion)
Tells the Finder that results will be sorted according to the given criterion, in ascending direction. |
|
ExtendedFinder |
sort(Finder.SortCriterion criterion,
Finder.SortDirection direction)
Tells the Finder that results will be sorted according to the given criterion and direction. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
@Nonnegative protected int firstResult
@Nonnegative protected int maxResults
@Nonnull protected java.util.List<it.tidalwave.util.spi.FinderSupport.Sorter<Type>> sorters
Constructor Detail |
---|
protected FinderSupport(@Nonnull java.lang.String name)
name
- the nameprotected FinderSupport()
Method Detail |
---|
@Nonnull public FinderSupport<Type,ExtendedFinder> clone()
clone
in class java.lang.Object
@Nonnull public ExtendedFinder from(@Nonnegative int firstResult)
Finder
that only a subset of found items will be returned, starting from the given position.
from
in interface Finder<Type>
Finder
@Nonnull public ExtendedFinder max(@Nonnegative int maxResults)
Finder
that only a maximum number of found items will be returned.
max
in interface Finder<Type>
Finder
@Nonnull public <AnotherType> Finder<AnotherType> ofType(@Nonnull java.lang.Class<AnotherType> type)
ofType
in interface Finder<Type>
Finder
@Nonnull public ExtendedFinder sort(@Nonnull Finder.SortCriterion criterion, @Nonnull Finder.SortDirection direction)
Finder
that results will be sorted according to the given criterion and direction.
sort
in interface Finder<Type>
criterion
- the sort criteriondirection
- the sort direction
Finder
@Nonnull public final ExtendedFinder sort(@Nonnull Finder.SortCriterion criterion)
Finder
that results will be sorted according to the given criterion, in ascending direction.
sort
in interface Finder<Type>
criterion
- the sort criterion
Finder
@Nonnull public Type result() throws NotFoundException
result
in interface Finder<Type>
NotFoundException
- if the search didn't find anything@Nonnull public Type firstResult() throws NotFoundException
firstResult
in interface Finder<Type>
NotFoundException
- if the search didn't find anything@Nonnull public java.util.List<? extends Type> results()
results
in interface Finder<Type>
@Nonnegative public int count()
count
in interface Finder<Type>
@Nonnull protected java.util.List<? extends Type> computeResults()
@Nonnull protected java.util.List<? extends Type> computeNeededResults()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |