Interface ComparatorBuilder

All Known Implementing Classes:
ComparatorBuilder.DefaultComparatorBuilder

public interface ComparatorBuilder
The comparator builder.
Author:
Christian Bremer
  • Method Details

    • newInstance

      static ComparatorBuilder newInstance()
      Creates a new comparator builder.
      Returns:
      the new comparator builder
    • add

      ComparatorBuilder add(Comparator<?> comparator)
      Adds the given comparator to this builder.
      Parameters:
      comparator - the comparator (can be null - then no comparator is added)
      Returns:
      the comparator builder
    • add

      default ComparatorBuilder add(String field)
      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

      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 be null)
      comparator - the comparator (can be null - 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 be null)
      valueExtractor - the value extractor (can be null)
      comparator - the comparator (can be null - then no comparator is added)
      Returns:
      the comparator builder
    • add

      default ComparatorBuilder add(SortOrderItem field)
      Creates and adds a value comparator for the given field ordering description.
      Parameters:
      field - the field ordering description (can be null)
      Returns:
      the comparator builder
    • add

      default ComparatorBuilder add(SortOrderItem 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 be null)
      valueExtractor - the value extractor (can be null)
      Returns:
      the comparator builder
    • addAll

      default ComparatorBuilder addAll(Collection<? extends SortOrderItem> sortOrders)
      Creates and adds value comparators for the given field ordering descriptions.
      Parameters:
      sortOrders - the ordering descriptions (can be null - no comparator will be added)
      Returns:
      the comparator builder
    • addAll

      default ComparatorBuilder addAll(Collection<? extends SortOrderItem> 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 be null - no comparator will be added)
      valueExtractor - the value extractor (can be null)
      Returns:
      the comparator builder
    • addAll

      default ComparatorBuilder addAll(Collection<? extends SortOrderItem> sortOrders, Function<SortOrderItem,Comparator<?>> comparatorFunction)
      Adds comparators for the given sortOrders ordering descriptions.
      Parameters:
      sortOrders - the ordering descriptions (can be null - no comparator will be added)
      comparatorFunction - the comparator function
      Returns:
      the comparator builder
    • addAll

      default ComparatorBuilder addAll(SortOrder sortOrder)
      Creates and adds value comparators for the given field ordering descriptions.
      Parameters:
      sortOrder - the ordering descriptions (can be null - no comparator will be added)
      Returns:
      the comparator builder
    • addAll

      default ComparatorBuilder addAll(SortOrder sortOrder, ValueExtractor valueExtractor)
      Creates and adds value comparators for the given field ordering descriptions. A custom value extractor can be specified.
      Parameters:
      sortOrder - the ordering descriptions (can be null - no comparator will be added)
      valueExtractor - the value extractor (can be null)
      Returns:
      the comparator builder
    • addAll

      default ComparatorBuilder addAll(SortOrder sortOrder, Function<SortOrderItem,Comparator<?>> comparatorFunction)
      Add all comparator builder.
      Parameters:
      sortOrder - the sort orders
      comparatorFunction - the comparator function
      Returns:
      the comparator builder
    • addAll

      default ComparatorBuilder addAll(String sortOrderText)
      Creates and adds value comparators for the given field ordering descriptions.
      Parameters:
      sortOrderText - the ordering descriptions (can be null - no comparator will be added)
      Returns:
      the comparator builder
    • addAll

      default ComparatorBuilder addAll(String sortOrderText, ValueExtractor valueExtractor)
      Creates and adds value comparators for the given field ordering descriptions. A custom value extractor can be specified.
      Parameters:
      sortOrderText - the ordering descriptions (can be null - no comparator will be added)
      valueExtractor - the value extractor (can be null)
      Returns:
      the comparator builder
    • addAll

      default ComparatorBuilder addAll(String sortOrderText, Function<SortOrderItem,Comparator<?>> comparatorFunction)
      Add all comparator builder.
      Parameters:
      sortOrderText - the sort orders
      comparatorFunction - the comparator function
      Returns:
      the comparator builder
    • build

      <T> Comparator<T> build()
      Build comparator.
      Type Parameters:
      T - the type parameter
      Returns:
      the comparator