eu.xtreemos.xosd.resmng.data
Class ResourceDescriptorComparator
java.lang.Object
eu.xtreemos.xosd.resmng.data.ResourceDescriptorComparator
- All Implemented Interfaces:
- java.util.Comparator
public class ResourceDescriptorComparator
- extends java.lang.Object
- implements java.util.Comparator
A class for comparing resource descriptor records by taking into account
multiple attributes of the record. The class implements methods for
denoting the order in which to compare the attributes and whether to
reverse the greater/lower relation. This comes handy when sorting the
records, whether ascending or descending by the attributes.
- Author:
- matej.artac@xlab.si
Field Summary |
protected java.util.ArrayList<java.lang.Boolean> |
ascendingComparison
|
protected java.util.ArrayList<java.lang.reflect.Field> |
attributesToCompare
An array of indices denoting the order of attribute comparison. |
(package private) static org.apache.log4j.Logger |
logger
|
Constructor Summary |
ResourceDescriptorComparator(java.util.ArrayList<java.lang.reflect.Field> attributesToCompare)
Instantiates the comparator for multi-attribute comparation of
resource records. |
ResourceDescriptorComparator(java.util.ArrayList<java.lang.reflect.Field> attributesToCompare,
java.util.ArrayList<java.lang.Boolean> ascendingComparison)
Instantiates the comparator for multi-attribute comparation of
resource records. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.util.Comparator |
equals |
logger
static final org.apache.log4j.Logger logger
attributesToCompare
protected java.util.ArrayList<java.lang.reflect.Field> attributesToCompare
- An array of indices denoting the order of attribute comparison.
ascendingComparison
protected java.util.ArrayList<java.lang.Boolean> ascendingComparison
ResourceDescriptorComparator
public ResourceDescriptorComparator(java.util.ArrayList<java.lang.reflect.Field> attributesToCompare)
- Instantiates the comparator for multi-attribute comparation of
resource records. The comparison for all the fields that take
part in the comparison will assume an ascending ordering.
- Parameters:
attributesToCompare
- The array of fields to be taken into the
comparison, in the order of importance. The comparison stops at the
first attribute that returns a non-equal result.
ResourceDescriptorComparator
public ResourceDescriptorComparator(java.util.ArrayList<java.lang.reflect.Field> attributesToCompare,
java.util.ArrayList<java.lang.Boolean> ascendingComparison)
- Instantiates the comparator for multi-attribute comparation of
resource records.
- Parameters:
attributesToCompare
- The array of fields to be taken into the
comparison, in the order of importance. The comparison stops at the
first attribute that returns a non-equal result.ascendingComparison
- The array denoting whether the ordering
in the comparison assumes an ascending order (value true) or a descending
order (value true) of the values for the corresponding field.
compare
public int compare(java.lang.Object arg0,
java.lang.Object arg1)
throws java.security.InvalidParameterException
- Specified by:
compare
in interface java.util.Comparator
- Throws:
java.security.InvalidParameterException
getAscendingComparison
public java.util.ArrayList<java.lang.Boolean> getAscendingComparison()
getAttributesToCompare
public java.util.ArrayList<java.lang.reflect.Field> getAttributesToCompare()
serialize
public ResourceDescriptorComparatorSerializable serialize()