com.unboundid.ldap.sdk.unboundidds.examples
Class FilterComparator

java.lang.Object
  extended by com.unboundid.ldap.sdk.unboundidds.examples.FilterComparator
All Implemented Interfaces:
java.io.Serializable, java.util.Comparator<Filter>

@NotMutable
@ThreadSafety(level=COMPLETELY_THREADSAFE)
public final class FilterComparator
extends java.lang.Object
implements java.util.Comparator<Filter>, java.io.Serializable

NOTE: This class is part of the Commercial Edition of the UnboundID LDAP SDK for Java. It is not available for use in applications that include only the Standard Edition of the LDAP SDK, and is not supported for use in conjunction with non-UnboundID products.
This class provides a comparator that may be used to define a relative order for search filters. The filter order will be based first on the filter type (in the following order: AND, OR, NOT, equality, substring, greater-or-equal, less-or-equal, presence, approximate match, extensible match), then based on the attribute name, and then by the assertion value. For AND and OR filters, with all other things equal, a filter with fewer components will be ordered before one with more components. For a substring filter with all other things equal, then a filter missing a substring element will be ordered before one with that element, and one with fewer subAny elements will be ordered before one with more subAny elements. For an extensible match filter with all other things being equal, a filter without an element will be ordered before one with that element.

See Also:
Serialized Form

Method Summary
 int compare(Filter f1, Filter f2)
          Determines a relative order for the provided filter objects.
 boolean equals(java.lang.Object o)
          Indicates whether the provided object is equal to this filter comparator.
static FilterComparator getInstance()
          Retrieves the singleton instance of this filter comparator.
 int hashCode()
          Retrieves a hash code for this filter comparator.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static FilterComparator getInstance()
Retrieves the singleton instance of this filter comparator.

Returns:
The singleton instance of this filter comparator.

compare

public int compare(Filter f1,
                   Filter f2)
Determines a relative order for the provided filter objects.

Specified by:
compare in interface java.util.Comparator<Filter>
Parameters:
f1 - The first filter for which to make the determination.
f2 - The second filter for which to make the determination.
Returns:
A negative value if the first filter should be ordered before the second, a positive value if the first filter should be ordered after the second, or zero if there is no difference in their relative orders.

hashCode

public int hashCode()
Retrieves a hash code for this filter comparator.

Overrides:
hashCode in class java.lang.Object
Returns:
A hash code for this filter comparator.

equals

public boolean equals(java.lang.Object o)
Indicates whether the provided object is equal to this filter comparator.

Specified by:
equals in interface java.util.Comparator<Filter>
Overrides:
equals in class java.lang.Object
Parameters:
o - The object for which to make the determination.
Returns:
true if the provided object is equal to this filter comparator, or false if not.