Class OrderImpl

java.lang.Object
de.digitalcollections.model.impl.paging.OrderImpl
All Implemented Interfaces:
Order

public class OrderImpl
extends java.lang.Object
implements Order
PropertyPath implements the pairing of an Direction and a property. It is used to provide input for Sorting. See Spring Data Commons, but more flat design and independent of Spring libraries.
  • Constructor Details

    • OrderImpl

      public OrderImpl()
    • OrderImpl

      public OrderImpl​(Direction direction, boolean ignoreCase, NullHandling nullHandling, java.lang.String property)
    • OrderImpl

      public OrderImpl​(Direction direction, java.lang.String property)
      Creates a new Order instance. if order is null then order defaults to Sorting.DEFAULT_DIRECTION
      Parameters:
      direction - can be null, will default to Sorting.DEFAULT_DIRECTION
      property - must not be null or empty.
    • OrderImpl

      public OrderImpl​(Direction direction, java.lang.String property, NullHandling nullHandlingHint)
      Creates a new Order instance. if order is null then order defaults to Sorting.DEFAULT_DIRECTION
      Parameters:
      direction - can be null, will default to Sorting.DEFAULT_DIRECTION
      property - must not be null or empty.
      nullHandlingHint - can be null, will default to NullHandling.NATIVE.
    • OrderImpl

      public OrderImpl​(java.lang.String property)
      Creates a new Order instance. Takes a single property. Direction defaults to Sorting.DEFAULT_DIRECTION.
      Parameters:
      property - must not be null or empty.
  • Method Details

    • setDirection

      public void setDirection​(Direction direction)
    • setIgnoreCase

      public void setIgnoreCase​(boolean ignoreCase)
    • setNullHandling

      public void setNullHandling​(NullHandling nullHandling)
    • setProperty

      public void setProperty​(java.lang.String property)
    • setSubProperty

      public void setSubProperty​(java.lang.String property)
    • equals

      public boolean equals​(java.lang.Object obj)
      Overrides:
      equals in class java.lang.Object
    • getDirection

      public Direction getDirection()
      Returns the order the property shall be sorted for.
      Specified by:
      getDirection in interface Order
      Returns:
      the order the property shall be sorted for
    • getNullHandling

      public NullHandling getNullHandling()
      Returns the used NullHandling hint, which can but may not be respected by the used datastore.
      Specified by:
      getNullHandling in interface Order
      Returns:
      the used NullHandling hint, which can but may not be respected by the used datastore.
    • getProperty

      public java.lang.String getProperty()
      Returns the property to order for.
      Specified by:
      getProperty in interface Order
      Returns:
      the property to order for
    • getSubProperty

      public java.util.Optional<java.lang.String> getSubProperty()
      Description copied from interface: Order
      Returns the optional sub property to order for.

      A sub property is always related to the main property.

      Specified by:
      getSubProperty in interface Order
      Returns:
      the optional sub property to order for
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class java.lang.Object
    • ignoreCase

      public Order ignoreCase()
      Returns a new Order with case insensitive sorting enabled.
      Specified by:
      ignoreCase in interface Order
      Returns:
      a new Order with case insensitive sorting enabled
    • isAscending

      public boolean isAscending()
      Returns whether sorting for this property shall be ascending.
      Specified by:
      isAscending in interface Order
      Returns:
      whether sorting for this property shall be ascending
    • isDescending

      public boolean isDescending()
      Returns whether sorting for this property shall be descending.
      Specified by:
      isDescending in interface Order
      Returns:
      whether sorting for this property shall be descending
    • isIgnoreCase

      public boolean isIgnoreCase()
      Returns whether or not the sort will be case sensitive.
      Specified by:
      isIgnoreCase in interface Order
      Returns:
      whether or not the sort will be case sensitive
    • nullsFirst

      public Order nullsFirst()
      Returns a Order with NullHandling.NULLS_FIRST as null handling hint.
      Specified by:
      nullsFirst in interface Order
      Returns:
      an Order with NullHandling#NULLS_FIRST as null handling hint
    • nullsLast

      public Order nullsLast()
      Returns a Order with NullHandling.NULLS_LAST as null handling hint.
      Specified by:
      nullsLast in interface Order
      Returns:
      an Order with NullHandling#NULLS_LAST as null handling hint.
    • nullsNative

      public Order nullsNative()
      Returns a Order with NullHandling.NATIVE as null handling hint.
      Specified by:
      nullsNative in interface Order
      Returns:
      an Order with NullHandling#NATIVE as null handling hint.
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object
    • with

      public Order with​(Direction direction)
      Returns a new Order with the given Direction.
      Specified by:
      with in interface Order
      Parameters:
      direction - given direction
      Returns:
      a new Order with the given Direction
    • with

      public Order with​(NullHandling nullHandling)
      Returns a Order with the given NullHandling.
      Specified by:
      with in interface Order
      Parameters:
      nullHandling - can be null.
      Returns:
      an Order with the given NullHandling
    • withProperties

      public Sorting withProperties​(java.lang.String... properties)
      Returns a new Sorting instance for the given properties.
      Specified by:
      withProperties in interface Order
      Parameters:
      properties - given properties
      Returns:
      a new SortingImpl for the given properties
    • withProperty

      public Order withProperty​(java.lang.String property)
      Returns a new Order
      Specified by:
      withProperty in interface Order
      Parameters:
      property - must not be null or empty.
      Returns:
      a new Order