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 boolean
Whether the sorting order isASCENDING
orDESCENDING
.private final ValueReference
<? super R, ?> The property on which to apply sorting.private static final long
For cross-version compatibility. -
Constructor Summary
ConstructorsConstructorDescriptionDefaultSortProperty
(ValueReference<? super R, ?> property, SortOrder order) Creates a newSortProperty
instance. -
Method Summary
Modifier and TypeMethodDescriptionint
Compares two resources for order.boolean
Compares this filter with the given object for equality.Returns the sort order:ASCENDING
orDESCENDING
.ValueReference
<? super R, ?> Returns the property to sort by.int
hashCode()
Computes a hash code value for this filter.private static Iterator
Returns an iterator for the given object.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods 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 isASCENDING
orDESCENDING
.
-
-
Constructor Details
-
DefaultSortProperty
DefaultSortProperty(ValueReference<? super R, ?> property, SortOrder order) Creates a newSortProperty
instance. It is caller responsibility to ensure that no argument is null.- Parameters:
property
- property on which to apply sorting.order
- the desired order:ASCENDING
orDESCENDING
.
-
-
Method Details
-
getValueReference
Returns the property to sort by.- Specified by:
getValueReference
in interfaceSortProperty<R>
-
getSortOrder
Returns the sort order:ASCENDING
orDESCENDING
.- Specified by:
getSortOrder
in interfaceSortProperty<R>
-
compare
Compares two resources for order. Returns a negative number ifr1
should be sorted beforer2
, a positive number ifr2
should 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:
compare
in 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 sinceClassCastException
should 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:
equals
in interfaceComparator<R>
- Overrides:
equals
in classObject
-