Package org.bremersee.comparator
Class ComparatorBuilder.DefaultComparatorBuilder
- java.lang.Object
-
- org.bremersee.comparator.ComparatorBuilder.DefaultComparatorBuilder
-
- All Implemented Interfaces:
ComparatorBuilder
- Enclosing interface:
- ComparatorBuilder
public static class ComparatorBuilder.DefaultComparatorBuilder extends Object implements ComparatorBuilder
The default comparator builder.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.bremersee.comparator.ComparatorBuilder
ComparatorBuilder.DefaultComparatorBuilder
-
-
Constructor Summary
Constructors Constructor Description DefaultComparatorBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ComparatorBuilderadd(String field, boolean asc, boolean ignoreCase, boolean nullIsFirst, ValueExtractor valueExtractor)Creates and adds a value comparator for the given field name or path to this builder.ComparatorBuilderadd(String field, ValueExtractor valueExtractor, Comparator<?> comparator)Adds the given comparator for the given field name or path to this builder.Comparator<Object>build()Build comparator.ComparatorBuilderfromWellKnownText(String wkt, WellKnownTextParser wktParser)Creates and adds value comparators for the given well known text description (seeComparatorField.toWkt(),ComparatorFields.toWkt()andWellKnownTextParser).
-
-
-
Method Detail
-
add
public ComparatorBuilder add(String field, ValueExtractor valueExtractor, Comparator<?> comparator)
Description copied from interface:ComparatorBuilderAdds the given comparator for the given field name or path to this builder. A custom value extractor can be specified.- Specified by:
addin interfaceComparatorBuilder- Parameters:
field- the field name or path (can benull)valueExtractor- the value extractor (can benull)comparator- the comparator (can benull- then no comparator is added)- Returns:
- the comparator builder
-
add
public ComparatorBuilder add(String field, boolean asc, boolean ignoreCase, boolean nullIsFirst, ValueExtractor valueExtractor)
Description copied from interface:ComparatorBuilderCreates and adds a value comparator for the given field name or path to this builder. A custom value extractor can be specified.- Specified by:
addin interfaceComparatorBuilder- Parameters:
field- the field name or path (can benull)asc-truefor an ascending order,falsefor a descending orderignoreCase-truefor a case insensitive order,falsefor a case sensitive ordernullIsFirst- specifies the order ofnullvaluesvalueExtractor- the value extractor- Returns:
- the comparator builder
-
fromWellKnownText
public ComparatorBuilder fromWellKnownText(String wkt, WellKnownTextParser wktParser)
Description copied from interface:ComparatorBuilderCreates and adds value comparators for the given well known text description (seeComparatorField.toWkt(),ComparatorFields.toWkt()andWellKnownTextParser).The syntax of the field ordering depends on the
WellKnownTextParser. The default isfieldNameOrPath0,asc,ignoreCase,nullIsFirst|fieldNameOrPath1,asc,ignoreCase,nullIsFirst
For example
person.lastName,asc,true,false|person.firstName,asc,true,false
- Specified by:
fromWellKnownTextin interfaceComparatorBuilder- Parameters:
wkt- the well known text (field ordering description)wktParser- the well known text parser (can benull)- Returns:
- the comparator builder
-
build
public Comparator<Object> build()
Description copied from interface:ComparatorBuilderBuild comparator.- Specified by:
buildin interfaceComparatorBuilder- Returns:
- the comparator
-
-