Interface SortBy<R>

Type Parameters:
R - the type of resources (e.g. Feature) to sort.
All Superinterfaces:
Comparator<R>

@UML(identifier="SortBy", specification=ISO_19143) public interface SortBy<R> extends Comparator<R>
Properties whose values shall be used to order the set of resources that satisfy a filter expression. SortBy provides an entry point to invoke the sorting mechanism of the filter expression processor. The sorting mechanism is not specified. The only requirement is that the sort sequence shall be consistent, given the same data set and sort request, between consecutive invocations of the sort.
Since:
3.1
  • Method Details

    • getSortProperties

      @UML(identifier="sortProperty", obligation=MANDATORY, specification=ISO_19143) List<SortProperty<R>> getSortProperties()
      The properties whose values are used for sorting. The list shall have a minimum of one element. In the event that multiple elements exist, the sequence of the SortProperty elements determines the order of ordering.
      Returns:
      properties whose values are used for sorting.
    • compare

      default 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.

      The comparison shall be consistent (ignoring unspecified aspects such as null values) with a comparison done "manually" by the following code:

      for (SortProperty<R> p : getSortProperties()) {
          int c = p.compare(r1, r2);
          if (c != 0) return c;
      }
      return 0;
      

      In order words, it shall be possible for the users to build their own SQL (or other language) query using above information and get the same results without invoking this compare(…) method.

      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:
      InvalidFilterValueException - if an expression cannot be applied on the given resources.
      ClassCastException - if the types of property values prevent them from being compared by this comparator.
      See Also: