Package org.apache.sis.filter
Class DefaultSortProperty<R>
java.lang.Object
org.apache.sis.filter.DefaultSortProperty<R>
- Type Parameters:
R- the type of resources (typicallyFeature) to sort.
- All Implemented Interfaces:
Serializable,Comparator<R>,SortProperty<R>
Defines a sort order based on a property and ascending/descending order.
- Since:
- 1.1
- Version:
- 1.1
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final booleanWhether the sorting order isASCENDINGorDESCENDING.private final ValueReference<? super R,?> The property on which to apply sorting.private static final longFor cross-version compatibility. -
Constructor Summary
ConstructorsConstructorDescriptionDefaultSortProperty(ValueReference<? super R, ?> property, SortOrder order) Creates a newSortPropertyinstance. -
Method Summary
Modifier and TypeMethodDescriptionintCompares two resources for order.booleanCompares this filter with the given object for equality.Returns the sort order:ASCENDINGorDESCENDING.ValueReference<? super R,?> Returns the property to sort by.inthashCode()Computes a hash code value for this filter.private static IteratorReturns an iterator for the given object.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Comparator
reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDFor cross-version compatibility.- See Also:
-
property
The property on which to apply sorting. -
descending
private final boolean descendingWhether the sorting order isASCENDINGorDESCENDING.
-
-
Constructor Details
-
DefaultSortProperty
DefaultSortProperty(ValueReference<? super R, ?> property, SortOrder order) Creates a newSortPropertyinstance. It is caller responsibility to ensure that no argument is null.- Parameters:
property- property on which to apply sorting.order- the desired order:ASCENDINGorDESCENDING.
-
-
Method Details
-
getValueReference
Returns the property to sort by.- Specified by:
getValueReferencein interfaceSortProperty<R>
-
getSortOrder
Returns the sort order:ASCENDINGorDESCENDING.- Specified by:
getSortOrderin interfaceSortProperty<R>
-
compare
Compares two resources for order. Returns a negative number ifr1should be sorted beforer2, a positive number ifr2should be afterr1, or 0 if both resources are equal. The ordering of null resources or null property values is unspecified and may change in any future version.- Specified by:
comparein interfaceComparator<R>- Parameters:
r1- the first resource to compare.r2- the second resource to compare.- Returns:
- negative if the first resource is before the second, positive for the converse, or 0 if equal.
- Throws:
ClassCastException- if the types of property values prevent them from being compared by this comparator.
-
iterator
Returns an iterator for the given object. Intentionally raw return type for allowing unchecked casts incompare(Object, Object). It is not as unsafe as it looks sinceClassCastExceptionshould happen soon if the type is incorrect and that exception is part of method contract. -
hashCode
public int hashCode()Computes a hash code value for this filter. -
equals
Compares this filter with the given object for equality.- Specified by:
equalsin interfaceComparator<R>- Overrides:
equalsin classObject
-