Class FieldComparators


  • public class FieldComparators
    extends FieldHolder<java.util.Comparator<?>>
    An internal holder of the comparators for fields described by their path without element index.

    Examples: name.first or names.first but not names[1].first or names.[1].first

    • Field Detail

    • Constructor Detail

      • FieldComparators

        public FieldComparators()
    • Method Detail

      • registerComparator

        public void registerComparator​(java.lang.String fieldLocation,
                                       java.util.Comparator<?> comparator)
        Registers the comparator for the given fieldLocation.
        Parameters:
        fieldLocation - the location where to apply the comparator
        comparator - the comparator itself
      • registerComparatorForFieldsMatchingRegexes

        public void registerComparatorForFieldsMatchingRegexes​(java.lang.String[] regexes,
                                                               java.util.Comparator<?> comparator)
        Registers the comparator for the given regexes field location.
        Parameters:
        regexes - the regexes field location where to apply the comparator
        comparator - the comparator to use for the regexes
      • hasComparatorForField

        public boolean hasComparatorForField​(java.lang.String fieldLocation)
        Checks, whether an any comparator is associated with the giving field location.
        Parameters:
        fieldLocation - the field location which association need to check
        Returns:
        is field location contain a custom comparator
      • getComparatorForField

        public java.util.Comparator<?> getComparatorForField​(java.lang.String fieldLocation)
        Retrieves a custom comparator, which is associated with the giving field location. If this location does not associate with any custom comparators - this method returns null.
        Parameters:
        fieldLocation - the field location that has to be associated with a comparator
        Returns:
        a custom comparator or null
      • comparatorByFields

        public java.util.stream.Stream<java.util.Map.Entry<java.lang.String,​java.util.Comparator<?>>> comparatorByFields()
        Returns a sequence of associated field-comparator pairs.
        Returns:
        sequence of field-comparator pairs
      • comparatorByRegexFields

        public java.util.stream.Stream<java.util.Map.Entry<java.util.List<java.util.regex.Pattern>,​java.util.Comparator<?>>> comparatorByRegexFields()
      • isEmpty

        public boolean isEmpty()
        Overrides:
        isEmpty in class FieldHolder<java.util.Comparator<?>>
        Returns:
        true is there are registered entities, false otherwise
      • hasFieldComparators

        public boolean hasFieldComparators()
      • hasRegexFieldComparators

        public boolean hasRegexFieldComparators()