inonit.domain.game.card
Class Sort

java.lang.Object
  |
  +--inonit.domain.game.card.Sort

public class Sort
extends java.lang.Object

Allows a set of objects to be sorted into an arbitrary order.


Inner Class Summary
static class Sort.Action
          An action to be taken as the result of comparing two objects during a sort.
static interface Sort.Order
          A logical ordering for a set of objects.
 
Method Summary
static Sort.Order compose(Sort.Order[] orders)
          Returns an Order which is a composite of the given Orders.
static Sort.Order reverse(Sort.Order order)
          Returns an Order which is the reverse of the given Order.
static java.lang.Object[] sort(java.lang.Object[] objects, Sort.Order order)
          Sorts an array into the given Sort.Order.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

reverse

public static Sort.Order reverse(Sort.Order order)
Returns an Order which is the reverse of the given Order.
Parameters:
order - An Order which will be reversed. Must not be null.
Returns:
An Order which is the reverse of the given Order.

compose

public static Sort.Order compose(Sort.Order[] orders)
Returns an Order which is a composite of the given Orders.
Parameters:
orders - a set of Orders to use to compose this Order. Must not be null. Must not be zero-length.
Returns:
An Order which is composed of the given Orders, as delegates. orders[0] will take precedence; if it returns EQUAL from its compare method, orders[1] will govern, and so on.

sort

public static java.lang.Object[] sort(java.lang.Object[] objects,
                                      Sort.Order order)
Sorts an array into the given Sort.Order.
Parameters:
objects - The array to sort. Must not be null. The array is sorted in place -- i.e., the array given as a parameter will be mutated into the correct order during the execution of this method.
order - The Order into which to sort objects. Must not be null.
Returns:
objects, for convenience. After this method is executed, it will be in the order specified by order.