Class DefaultSortProperty<R>

java.lang.Object
org.apache.sis.filter.DefaultSortProperty<R>
Type Parameters:
R - the type of resources (typically Feature) to sort.
All Implemented Interfaces:
Serializable, Comparator<R>, SortProperty<R>

final class DefaultSortProperty<R> extends Object implements SortProperty<R>, Serializable
Defines a sort order based on a property and ascending/descending order.
Since:
1.1
Version:
1.1
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      For cross-version compatibility.
      See Also:
    • property

      private final ValueReference<? super R,?> property
      The property on which to apply sorting.
    • descending

      private final boolean descending
      Whether the sorting order is ASCENDING or DESCENDING.
  • Constructor Details

    • DefaultSortProperty

      DefaultSortProperty(ValueReference<? super R,?> property, SortOrder order)
      Creates a new SortProperty 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 or DESCENDING.
  • Method Details

    • getValueReference

      public ValueReference<? super R,?> getValueReference()
      Returns the property to sort by.
      Specified by:
      getValueReference in interface SortProperty<R>
    • getSortOrder

      public SortOrder getSortOrder()
      Returns the sort order: ASCENDING or DESCENDING.
      Specified by:
      getSortOrder in interface SortProperty<R>
    • compare

      public int compare(R r1, R r2)
      Compares two resources for order. Returns a negative number if r1 should be sorted before r2, a positive number if r2 should be after r1, 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 interface Comparator<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

      private static Iterator iterator(Object o)
      Returns an iterator for the given object. Intentionally raw return type for allowing unchecked casts in compare(Object, Object). It is not as unsafe as it looks since ClassCastException 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.
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Compares this filter with the given object for equality.
      Specified by:
      equals in interface Comparator<R>
      Overrides:
      equals in class Object