Spring Data Commons

org.springframework.data.domain
Class Sort

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

public class Sort
extends Object
implements Iterable<Sort.Order>, 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
          Property implements the pairing of an Order and a property.
 
Field Summary
static Sort.Direction DEFAULT_DIRECTION
           
 
Constructor Summary
Sort(List<Sort.Order> orders)
          Creates a new Sort instance.
Sort(Sort.Direction direction, List<String> properties)
          Creates a new Sort instance.
Sort(Sort.Direction direction, String... properties)
          Creates a new Sort instance.
Sort(Sort.Order... orders)
           
Sort(String... properties)
          Creates a new Sort instance.
 
Method Summary
 boolean equals(Object obj)
           
 Sort.Order getOrderFor(String property)
          Returns the order registered for the given property.
 int hashCode()
           
 Iterator<Sort.Order> iterator()
           
 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(List<Sort.Order> orders)
Creates a new Sort instance.

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

Sort

public Sort(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,
            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,
            List<String> properties)
Creates a new Sort instance.

Parameters:
direction -
properties -
Method Detail

getOrderFor

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

Parameters:
property -
Returns:

iterator

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

equals

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

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object

Spring Data Commons

Copyright © 2011. All Rights Reserved.