com.avaje.ebean
Class OrderBy<T>

java.lang.Object
  extended by com.avaje.ebean.OrderBy<T>
All Implemented Interfaces:
Serializable

public final 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.

Author:
rbygrave
See Also:
Serialized Form

Nested Class Summary
static class OrderBy.Property
          A property and its ascending descending order.
 
Constructor Summary
OrderBy()
          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
 void add(OrderBy.Property p)
          Add a property to the order by.
 Query<T> asc(String propertyName)
          Add a property with ascending order to this OrderBy.
 OrderBy<T> copy()
          Return a copy of the OrderBy.
 Query<T> desc(String propertyName)
          Add a property with descending order to this OrderBy.
 boolean equals(Object obj)
           
 List<OrderBy.Property> getProperties()
          Return the properties for this OrderBy.
 Query<T> getQuery()
          Return the associated query if there is one.
 int hash()
          Return a hash value for this OrderBy.
 int hashCode()
           
 boolean isEmpty()
          Return true if this OrderBy does not have any properties.
 void reverse()
          Reverse the ascending/descending order on all the properties.
 void setQuery(Query<T> query)
          Associate this OrderBy with a query.
 String toString()
           
 String toStringFormat()
          Returns the OrderBy in string format.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

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 Detail

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.


desc

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


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(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()
Overrides:
hashCode in class Object

hash

public int hash()
Return a hash value for this OrderBy. This can be to determine logical equality for OrderBy clauses.



Copyright © 2010. All Rights Reserved.