Class ElementPropertyComparator
- java.lang.Object
-
- uk.gov.gchq.gaffer.data.element.comparison.ElementPropertyComparator
-
- All Implemented Interfaces:
Comparator<Element>
,ElementComparator
public class ElementPropertyComparator extends Object implements ElementComparator
AnElementComparator
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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ElementPropertyComparator.Builder
-
Constructor Summary
Constructors Constructor Description ElementPropertyComparator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
_compare(Object val1, Object val2)
int
compare(Element e1, Element e2)
Set<Pair<String,String>>
getComparableGroupPropertyPairs()
This should return a set all properties that the comparator requires to be of type Comparable.Comparator
getComparator()
Set<String>
getGroups()
String
getProperty()
boolean
isReversed()
void
setComparator(Comparator comparator)
void
setGroups(Set<String> groups)
void
setProperty(String property)
void
setReversed(boolean reversed)
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
-
-
-
Method Detail
-
compare
public int compare(Element e1, Element e2)
- Specified by:
compare
in interfaceComparator<Element>
-
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 interfaceElementComparator
- 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)
-
isReversed
public boolean isReversed()
-
setReversed
public void setReversed(boolean reversed)
-
getComparator
public Comparator getComparator()
-
setComparator
public void setComparator(Comparator comparator)
-
-