Package org.bremersee.comparator
Interface ComparatorBuilder
-
- All Known Implementing Classes:
ComparatorBuilder.DefaultComparatorBuilder
public interface ComparatorBuilderThe comparator builder.- Author:
- Christian Bremer
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classComparatorBuilder.DefaultComparatorBuilderThe default comparator builder.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default ComparatorBuilderadd(String field, boolean asc, boolean ignoreCase, boolean nullIsFirst)Creates and adds a value comparator for the given field name or path to this builder.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.default ComparatorBuilderadd(String field, Comparator<?> comparator)Adds the given 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.default ComparatorBuilderadd(Comparator<?> comparator)Adds the given comparator to this builder.default ComparatorBuilderadd(ComparatorField field)Creates and adds a value comparator for the given field ordering description.default ComparatorBuilderadd(ComparatorField field, ValueExtractor valueExtractor)Creates and adds a value comparator for the given field ordering description.default ComparatorBuilderaddAll(Collection<? extends ComparatorField> fields)Creates and adds value comparators for the given field ordering descriptions.default ComparatorBuilderaddAll(Collection<? extends ComparatorField> fields, ValueExtractor valueExtractor)Creates and adds value comparators for the given field ordering descriptions.default ComparatorBuilderaddAll(ComparatorFields comparatorFields)Creates and adds value comparators for the given field ordering descriptions.default ComparatorBuilderaddAll(ComparatorFields comparatorFields, ValueExtractor valueExtractor)Creates and adds value comparators for the given field ordering descriptions.Comparator<Object>build()Build comparator.static ComparatorBuilderbuilder()Creates a new comparator builder.default ComparatorBuilderfromWellKnownText(String wkt)Creates and adds value comparators for the given well known text description (seeComparatorField.toWkt(),ComparatorFields.toWkt()andWellKnownTextParser).ComparatorBuilderfromWellKnownText(String wkt, WellKnownTextParser wktParser)Creates and adds value comparators for the given well known text description (seeComparatorField.toWkt(),ComparatorFields.toWkt()andWellKnownTextParser).
-
-
-
Method Detail
-
builder
static ComparatorBuilder builder()
Creates a new comparator builder.- Returns:
- the new comparator builder
-
add
default ComparatorBuilder add(Comparator<?> comparator)
Adds the given comparator to this builder.- Parameters:
comparator- the comparator (can benull- then no comparator is added)- Returns:
- the comparator builder
-
add
default ComparatorBuilder add(String field, Comparator<?> comparator)
Adds the given comparator for the given field name or path to this builder.- Parameters:
field- the field name or path (can benull)comparator- the comparator (can benull- then no comparator is added)- Returns:
- the comparator builder
-
add
ComparatorBuilder add(String field, ValueExtractor valueExtractor, Comparator<?> comparator)
Adds the given comparator for the given field name or path to this builder. A custom value extractor can be specified.- 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
default ComparatorBuilder add(String field, boolean asc, boolean ignoreCase, boolean nullIsFirst)
Creates and adds a value comparator for the given field name or path to this builder.- 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 ofnullvalues- Returns:
- the comparator builder
-
add
ComparatorBuilder add(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. A custom value extractor can be specified.- 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
-
add
default ComparatorBuilder add(ComparatorField field)
Creates and adds a value comparator for the given field ordering description.- Parameters:
field- the field ordering description (can benull)- Returns:
- the comparator builder
-
add
default ComparatorBuilder add(ComparatorField field, ValueExtractor valueExtractor)
Creates and adds a value comparator for the given field ordering description. A custom value extractor can be specified.- Parameters:
field- the field ordering description (can benull)valueExtractor- the value extractor- Returns:
- the comparator builder
-
addAll
default ComparatorBuilder addAll(Collection<? extends ComparatorField> fields)
Creates and adds value comparators for the given field ordering descriptions.- Parameters:
fields- the ordering descriptions (can benull- no comparator will be added)- Returns:
- the comparator builder
-
addAll
default ComparatorBuilder addAll(Collection<? extends ComparatorField> fields, ValueExtractor valueExtractor)
Creates and adds value comparators for the given field ordering descriptions. A custom value extractor can be specified.- Parameters:
fields- the ordering descriptions (can benull- no comparator will be added)valueExtractor- the value extractor- Returns:
- the comparator builder
-
addAll
default ComparatorBuilder addAll(ComparatorFields comparatorFields)
Creates and adds value comparators for the given field ordering descriptions.- Parameters:
comparatorFields- the ordering descriptions (can benull- no comparator will be added)- Returns:
- the comparator builder
-
addAll
default ComparatorBuilder addAll(ComparatorFields comparatorFields, ValueExtractor valueExtractor)
Creates and adds value comparators for the given field ordering descriptions. A custom value extractor can be specified.- Parameters:
comparatorFields- the ordering descriptions (can benull- no comparator will be added)valueExtractor- the value extractor- Returns:
- the comparator builder
-
fromWellKnownText
default ComparatorBuilder fromWellKnownText(String wkt)
Creates and adds value comparators for the given well known text description (seeComparatorField.toWkt(),ComparatorFields.toWkt()andWellKnownTextParser).The syntax of the field ordering description is
fieldNameOrPath0,asc,ignoreCase,nullIsFirst|fieldNameOrPath1,asc,ignoreCase,nullIsFirst
For example
person.lastName,asc,true,false|person.firstName,asc,true,false
- Parameters:
wkt- the well known text (field ordering description)- Returns:
- the comparator builder
-
fromWellKnownText
ComparatorBuilder fromWellKnownText(String wkt, WellKnownTextParser wktParser)
Creates 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
- Parameters:
wkt- the well known text (field ordering description)wktParser- the well known text parser (can benull)- Returns:
- the comparator builder
-
build
Comparator<Object> build()
Build comparator.- Returns:
- the comparator
-
-