Package com.tangosol.coherence.rest.util
Class ComparatorBuilder
- java.lang.Object
-
- com.tangosol.coherence.rest.util.ComparatorBuilder
-
public class ComparatorBuilder extends Object
Comparator builder that provides a small set of builder methods to simplify creation of a chain ofExtractorComparator
s from givenValueExtractor
s.- Author:
- ic 2011.06.30
- See Also:
ExtractorComparator
,ValueExtractor
-
-
Constructor Summary
Constructors Constructor Description ComparatorBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
add(Comparator comparator)
Append specified comparator to the end of list of comparators owned by this builder.ComparatorBuilder
asc(ValueExtractor extractor)
Add comparator to this builder.ComparatorBuilder
asc(String sExpr)
Add comparator to this builder.Comparator
build()
Build comparator.protected Comparator
createComparator(ValueExtractor extractor)
Create extractor comparator.protected Comparator
createComparator(String sExpr)
Create extractor comparator.protected ValueExtractor
createExtractor(String sExpr)
Create expression extractor.ComparatorBuilder
desc(ValueExtractor extractor)
Add comparator to this builder.ComparatorBuilder
desc(String sExpr)
Add comparator to builder.protected Comparator
inverse(Comparator comparator)
Reverse ordering of a given comparator.protected Comparator
safe(Comparator comparator)
Wrap given comparator with aSafeComparator
.
-
-
-
Method Detail
-
asc
public ComparatorBuilder asc(String sExpr)
Add comparator to this builder.- Parameters:
sExpr
- expression used to create an expression extractor- Returns:
- this ComparatorBuilder
-
asc
public ComparatorBuilder asc(ValueExtractor extractor)
Add comparator to this builder.- Parameters:
extractor
- extractor used to extract values- Returns:
- this ComparatorBuilder
-
desc
public ComparatorBuilder desc(String sExpr)
Add comparator to builder.- Parameters:
sExpr
- expression used to create expression extractor- Returns:
- this ComparatorBuilder
-
desc
public ComparatorBuilder desc(ValueExtractor extractor)
Add comparator to this builder.- Parameters:
extractor
- extractor used to extract values- Returns:
- this ComparatorBuilder
-
build
public Comparator build()
Build comparator.- Returns:
- comparator representing current state of builder
-
add
protected void add(Comparator comparator)
Append specified comparator to the end of list of comparators owned by this builder.- Parameters:
comparator
- comparator to add
-
inverse
protected Comparator inverse(Comparator comparator)
Reverse ordering of a given comparator.- Parameters:
comparator
- comparator to be reversed- Returns:
- a reversed comparator
-
createComparator
protected Comparator createComparator(String sExpr)
Create extractor comparator.- Parameters:
sExpr
- expression used to create expression extractor- Returns:
- comparator that will evaluate given expression when comparing values
-
createComparator
protected Comparator createComparator(ValueExtractor extractor)
Create extractor comparator.- Parameters:
extractor
- extractor used while comparing values- Returns:
- comparator that will use given extractor when comparing values
-
safe
protected Comparator safe(Comparator comparator)
Wrap given comparator with aSafeComparator
.- Parameters:
comparator
- to be wrapped- Returns:
- SafeComparator wrapping given comparator
-
createExtractor
protected ValueExtractor createExtractor(String sExpr)
Create expression extractor.- Parameters:
sExpr
- expression to create extractor for- Returns:
- extractor for the specified expression
-
-