Package org.bremersee.comparator
Interface ComparatorBuilder
- All Known Implementing Classes:
ComparatorBuilder.DefaultComparatorBuilder
public interface ComparatorBuilder
The comparator builder.
- Author:
- Christian Bremer
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classThe default comparator builder. -
Method Summary
Modifier and TypeMethodDescriptiondefault ComparatorBuilderAdds a default comparator for the given field (the value of the field must be comparable).default ComparatorBuilderCreates and adds a value comparator for the given field name or path to this builder.default 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.default ComparatorBuilderadd(String field, ValueExtractor valueExtractor, Comparator<?> comparator) Adds the given comparator for the given field name or path to this builder.add(Comparator<?> comparator) Adds the given comparator to this builder.default ComparatorBuilderCreates and adds a value comparator for the given field ordering description.default ComparatorBuilderadd(SortOrder field, ValueExtractor valueExtractor) Creates and adds a value comparator for the given field ordering description.default ComparatorBuilderaddAll(Collection<? extends SortOrder> sortOrders) Creates and adds value comparators for the given field ordering descriptions.default ComparatorBuilderaddAll(Collection<? extends SortOrder> sortOrders, Function<SortOrder, Comparator<?>> comparatorFunction) Adds comparators for the given sortOrders ordering descriptions.default ComparatorBuilderaddAll(Collection<? extends SortOrder> sortOrders, ValueExtractor valueExtractor) Creates and adds value comparators for the given field ordering descriptions.default ComparatorBuilderaddAll(SortOrders sortOrders) Creates and adds value comparators for the given field ordering descriptions.default ComparatorBuilderaddAll(SortOrders sortOrders, Function<SortOrder, Comparator<?>> comparatorFunction) Add all comparator builder.default ComparatorBuilderaddAll(SortOrders sortOrders, ValueExtractor valueExtractor) Creates and adds value comparators for the given field ordering descriptions.<T> Comparator<T>build()Build comparator.static ComparatorBuilderCreates a new comparator builder.
-
Method Details
-
newInstance
Creates a new comparator builder.- Returns:
- the new comparator builder
-
add
Adds the given comparator to this builder.- Parameters:
comparator- the comparator (can benull- then no comparator is added)- Returns:
- the comparator builder
-
add
Adds a default comparator for the given field (the value of the field must be comparable).- Parameters:
field- the field- Returns:
- the comparator builder
-
add
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
default 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
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
default 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 (can benull)- Returns:
- the comparator builder
-
add
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
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 (can benull)- Returns:
- the comparator builder
-
addAll
Creates and adds value comparators for the given field ordering descriptions.- Parameters:
sortOrders- the ordering descriptions (can benull- no comparator will be added)- Returns:
- the comparator builder
-
addAll
default ComparatorBuilder addAll(Collection<? extends SortOrder> sortOrders, ValueExtractor valueExtractor) Creates and adds value comparators for the given field ordering descriptions. A custom value extractor can be specified.- Parameters:
sortOrders- the ordering descriptions (can benull- no comparator will be added)valueExtractor- the value extractor (can benull)- Returns:
- the comparator builder
-
addAll
default ComparatorBuilder addAll(Collection<? extends SortOrder> sortOrders, Function<SortOrder, Comparator<?>> comparatorFunction) Adds comparators for the given sortOrders ordering descriptions.- Parameters:
sortOrders- the ordering descriptions (can benull- no comparator will be added)comparatorFunction- the comparator function- Returns:
- the comparator builder
-
addAll
Creates and adds value comparators for the given field ordering descriptions.- Parameters:
sortOrders- the ordering descriptions (can benull- no comparator will be added)- Returns:
- the comparator builder
-
addAll
Creates and adds value comparators for the given field ordering descriptions. A custom value extractor can be specified.- Parameters:
sortOrders- the ordering descriptions (can benull- no comparator will be added)valueExtractor- the value extractor (can benull)- Returns:
- the comparator builder
-
addAll
default ComparatorBuilder addAll(SortOrders sortOrders, Function<SortOrder, Comparator<?>> comparatorFunction) Add all comparator builder.- Parameters:
sortOrders- the sort orderscomparatorFunction- the comparator function- Returns:
- the comparator builder
-
build
Build comparator.- Type Parameters:
T- the type parameter- Returns:
- the comparator
-