Module io.ebean.api
Package io.ebean

Class OrderBy<T>

java.lang.Object
io.ebean.OrderBy<T>
All Implemented Interfaces:
Serializable

public class OrderBy<T> extends Object implements Serializable
Represents an Order By for a Query.

Is a ordered list of OrderBy.Property objects each specifying a property and whether it is ascending or descending order.

Typically you will not construct an OrderBy yourself but use one that exists on the Query object.

See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    A property and its ascending descending order.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create an empty OrderBy with no associated query.
    OrderBy(Query<T> query, String orderByClause)
    Construct with a given query and order by clause.
    OrderBy(String orderByClause)
    Create an orderBy parsing the order by clause.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Add a property to the order by.
    void
    add(String rawExpression)
    Add to the order by by parsing a raw expression.
    asc(String propertyName)
    Add a property with ascending order to this OrderBy.
    asc(String propertyName, String collation)
    Add a property with ascending order to this OrderBy.
    Clear the orderBy removing any current order by properties.
    boolean
    containsProperty(String propertyName)
    Return true if the property is known to be contained in the order by clause.
    Return a copy of the OrderBy.
    Return a copy of this OrderBy with the path trimmed.
    desc(String propertyName)
    Add a property with descending order to this OrderBy.
    desc(String propertyName, String collation)
    Add a property with descending order to this OrderBy.
    boolean
     
    Return the properties for this OrderBy.
    Return the associated query if there is one.
    int
    Return a hash value for this OrderBy.
    boolean
    Return true if this OrderBy does not have any properties.
    void
    Reverse the ascending/descending order on all the properties.
    void
    setQuery(Query<T> query)
    Associate this OrderBy with a query.
    boolean
    Return true if this order by can be used in select clause.
     
    Returns the OrderBy in string format.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • OrderBy

      public OrderBy()
      Create an empty OrderBy with no associated query.
    • OrderBy

      public OrderBy(String orderByClause)
      Create an orderBy parsing the order by clause.

      The order by clause follows SQL order by clause with comma's between each property and optionally "asc" or "desc" to represent ascending or descending order respectively.

    • OrderBy

      public OrderBy(Query<T> query, String orderByClause)
      Construct with a given query and order by clause.
  • Method Details

    • reverse

      public void reverse()
      Reverse the ascending/descending order on all the properties.
    • asc

      public Query<T> asc(String propertyName)
      Add a property with ascending order to this OrderBy.
    • asc

      public Query<T> asc(String propertyName, String collation)
      Add a property with ascending order to this OrderBy.
    • desc

      public Query<T> desc(String propertyName)
      Add a property with descending order to this OrderBy.
    • desc

      public Query<T> desc(String propertyName, String collation)
      Add a property with descending order to this OrderBy.
    • containsProperty

      public boolean containsProperty(String propertyName)
      Return true if the property is known to be contained in the order by clause.
    • copyWithTrim

      public OrderBy<T> copyWithTrim(String path)
      Return a copy of this OrderBy with the path trimmed.
    • getProperties

      public List<OrderBy.Property> getProperties()
      Return the properties for this OrderBy.
    • isEmpty

      public boolean isEmpty()
      Return true if this OrderBy does not have any properties.
    • getQuery

      public Query<T> getQuery()
      Return the associated query if there is one.
    • setQuery

      public void setQuery(Query<T> query)
      Associate this OrderBy with a query.
    • copy

      public OrderBy<T> copy()
      Return a copy of the OrderBy.
    • add

      public void add(String rawExpression)
      Add to the order by by parsing a raw expression.
    • add

      public void add(OrderBy.Property p)
      Add a property to the order by.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toStringFormat

      public String toStringFormat()
      Returns the OrderBy in string format.
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Return a hash value for this OrderBy. This can be to determine logical equality for OrderBy clauses.
      Overrides:
      hashCode in class Object
    • clear

      public OrderBy<T> clear()
      Clear the orderBy removing any current order by properties.

      This is intended to be used when some code creates a query with a 'default' order by clause and some other code may clear the 'default' order by clause and replace.

    • supportsSelect

      public boolean supportsSelect()
      Return true if this order by can be used in select clause.