Spring Data Commons

org.springframework.data.domain
Class Sort

java.lang.Object
  extended by org.springframework.data.domain.Sort
All Implemented Interfaces:
java.io.Serializable, java.lang.Iterable<Sort.Order>

public class Sort
extends java.lang.Object
implements java.lang.Iterable<Sort.Order>, java.io.Serializable

Sort option for queries. You have to provide at least a list of properties to sort for that must not include null or empty strings. The direction defaults to .

Author:
Oliver Gierke
See Also:
Serialized Form

Nested Class Summary
static class Sort.Direction
          Enumeration for sort directions.
static class Sort.Order
          PropertyPath implements the pairing of an Order and a property.
 
Field Summary
static Sort.Direction DEFAULT_DIRECTION
           
 
Constructor Summary
Sort(java.util.List<Sort.Order> orders)
          Creates a new Sort instance.
Sort(Sort.Direction direction, java.util.List<java.lang.String> properties)
          Creates a new Sort instance.
Sort(Sort.Direction direction, java.lang.String... properties)
          Creates a new Sort instance.
Sort(Sort.Order... orders)
           
Sort(java.lang.String... properties)
          Creates a new Sort instance.
 
Method Summary
 Sort and(Sort sort)
          Returns a new Sort consisting of the Sort.Orders of the current Sort combined with the given ones.
 boolean equals(java.lang.Object obj)
           
 Sort.Order getOrderFor(java.lang.String property)
          Returns the order registered for the given property.
 int hashCode()
           
 java.util.Iterator<Sort.Order> iterator()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_DIRECTION

public static final Sort.Direction DEFAULT_DIRECTION
Constructor Detail

Sort

public Sort(Sort.Order... orders)

Sort

public Sort(java.util.List<Sort.Order> orders)
Creates a new Sort instance.

Parameters:
orders - must not be null or contain null or empty strings

Sort

public Sort(java.lang.String... properties)
Creates a new Sort instance. Order defaults to .

Parameters:
properties - must not be null or contain null or empty strings

Sort

public Sort(Sort.Direction direction,
            java.lang.String... properties)
Creates a new Sort instance.

Parameters:
direction - defaults to (for null cases, too)
properties - must not be null or contain null or empty strings

Sort

public Sort(Sort.Direction direction,
            java.util.List<java.lang.String> properties)
Creates a new Sort instance.

Parameters:
direction -
properties -
Method Detail

and

public Sort and(Sort sort)
Returns a new Sort consisting of the Sort.Orders of the current Sort combined with the given ones.

Parameters:
sort - can be null.
Returns:

getOrderFor

public Sort.Order getOrderFor(java.lang.String property)
Returns the order registered for the given property.

Parameters:
property -
Returns:

iterator

public java.util.Iterator<Sort.Order> iterator()
Specified by:
iterator in interface java.lang.Iterable<Sort.Order>

equals

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

hashCode

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

toString

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

Spring Data Commons

Copyright © 2012. All Rights Reserved.