Class ElementPropertyComparator

  • All Implemented Interfaces:
    Comparator<Element>, ElementComparator

    public class ElementPropertyComparator
    extends Object
    implements ElementComparator
    An ElementComparator implementation to use when making comparisons based on a single element property (e.g. a count field).

    You must provide the property name and the set of element groups that contain that property.

    Any elements that are compared that are not in one of the provided groups will be returned 'last' in the result.

    Any elements that are compared that do not have the provided property will also be returned 'last' in the result.

    There is a reversed option to allow you to flip the comparison value.

    • Constructor Detail

      • ElementPropertyComparator

        public ElementPropertyComparator()
    • Method Detail

      • _compare

        public int _compare​(Object val1,
                            Object val2)
      • getComparableGroupPropertyPairs

        public Set<Pair<String,​String>> getComparableGroupPropertyPairs()
        Description copied from interface: ElementComparator
        This should return a set all properties that the comparator requires to be of type Comparable. As properties are associated with a Group we need to return Group,Property pairs. This is used to validate the the ElementComparator against the schema.
        Specified by:
        getComparableGroupPropertyPairs in interface ElementComparator
        Returns:
        set of group,property pairs, in which all properties are required to be comparable.
      • getProperty

        public String getProperty()
      • setProperty

        public void setProperty​(String property)
      • setGroups

        public void setGroups​(Set<String> groups)
      • isReversed

        public boolean isReversed()
      • setReversed

        public void setReversed​(boolean reversed)
      • getComparator

        public Comparator getComparator()
      • setComparator

        public void setComparator​(Comparator comparator)