net.dpml.cli.util
Class Comparators

java.lang.Object
  extended by net.dpml.cli.util.Comparators

public final class Comparators
extends Object

A collection of Comparators suitable for use with Option instances.

Version:
1.0.0
Author:
Digital Product Meta Library

Method Summary
static Comparator chain(Comparator[] comparators)
          Chains an array of comparators together.
static Comparator chain(Comparator c0, Comparator c1)
          Chains comparators together.
static Comparator chain(Comparator c0, Comparator c1, Comparator c2)
          Chains comparators together.
static Comparator chain(Comparator c0, Comparator c1, Comparator c2, Comparator c3)
          Chains comparators together.
static Comparator chain(Comparator c0, Comparator c1, Comparator c2, Comparator c3, Comparator c4)
          Chains comparators together.
static Comparator chain(List comparators)
          Chains comparators together.
static Comparator commandFirst()
          Forces Command instances to appear at the beginning of lists
static Comparator commandLast()
          Forces Command instances to appear at the end of lists
static Comparator defaultOptionFirst()
          Forces DefaultOption instances to appear at the beginning of lists
static Comparator defaultOptionLast()
          Forces DefaultOption instances to appear at the end of lists
static Comparator groupFirst()
          Forces Group instances to appear at the beginning of lists
static Comparator groupLast()
          Forces Group instances to appear at the end of lists
static Comparator namedFirst(String name)
          Forces Comparators with a particular trigger to appear at the beginning of lists
static Comparator namedLast(String name)
          Forces Comparators with a particular trigger to appear at the end of lists
static Comparator preferredNameFirst()
          Orders Options by preferredName
static Comparator preferredNameLast()
          Orders Options by preferredName, reversed
static Comparator requiredFirst()
          Orders Options grouping required Options first
static Comparator requiredLast()
          Orders Options grouping required Options last
static Comparator switchFirst()
          Forces Switch instances to appear at the beginning of lists
static Comparator switchLast()
          Forces Switch instances to appear at the end of lists
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

chain

public static Comparator chain(Comparator c0,
                               Comparator c1)
Chains comparators together.

Parameters:
c0 - a comparator
c1 - a comparator
Returns:
a chained comparator
See Also:
chain(Comparator[])

chain

public static Comparator chain(Comparator c0,
                               Comparator c1,
                               Comparator c2)
Chains comparators together.

Parameters:
c0 - a comparator
c1 - a comparator
c2 - a comparator
Returns:
a chained comparator
See Also:
chain(Comparator[])

chain

public static Comparator chain(Comparator c0,
                               Comparator c1,
                               Comparator c2,
                               Comparator c3)
Chains comparators together.

Parameters:
c0 - a comparator
c1 - a comparator
c2 - a comparator
c3 - a comparator
Returns:
a chained comparator
See Also:
chain(Comparator[])

chain

public static Comparator chain(Comparator c0,
                               Comparator c1,
                               Comparator c2,
                               Comparator c3,
                               Comparator c4)
Chains comparators together.

Parameters:
c0 - a comparator
c1 - a comparator
c2 - a comparator
c3 - a comparator
c4 - a comparator
Returns:
a chained comparator
See Also:
chain(Comparator[])

chain

public static Comparator chain(List comparators)
Chains comparators together.

Parameters:
comparators - a List of comparators to chain together
Returns:
a chained comparator
See Also:
chain(Comparator[])

chain

public static Comparator chain(Comparator[] comparators)
Chains an array of comparators together. Each Comparator will be called in turn until one of them return a non-zero value, this value will be returned.

Parameters:
comparators - the array of comparators
Returns:
a chained comparator

groupFirst

public static Comparator groupFirst()
Forces Group instances to appear at the beginning of lists

Returns:
a new comparator
See Also:
Group

groupLast

public static Comparator groupLast()
Forces Group instances to appear at the end of lists

Returns:
a new comparator
See Also:
Group

switchFirst

public static Comparator switchFirst()
Forces Switch instances to appear at the beginning of lists

Returns:
a new comparator
See Also:
Switch

switchLast

public static Comparator switchLast()
Forces Switch instances to appear at the end of lists

Returns:
a new comparator
See Also:
Switch

commandFirst

public static Comparator commandFirst()
Forces Command instances to appear at the beginning of lists

Returns:
a new comparator
See Also:
Command

commandLast

public static Comparator commandLast()
Forces Command instances to appear at the end of lists

Returns:
a new comparator
See Also:
Command

defaultOptionFirst

public static Comparator defaultOptionFirst()
Forces DefaultOption instances to appear at the beginning of lists

Returns:
a new comparator
See Also:
DefaultOption

defaultOptionLast

public static Comparator defaultOptionLast()
Forces DefaultOption instances to appear at the end of lists

Returns:
a new comparator
See Also:
DefaultOption

namedFirst

public static Comparator namedFirst(String name)
Forces Comparators with a particular trigger to appear at the beginning of lists

Parameters:
name - the trigger name to select
Returns:
a new comparator
See Also:
Option.getTriggers()

namedLast

public static Comparator namedLast(String name)
Forces Comparators with a particular trigger to appear at the end of lists

Parameters:
name - the trigger name to select
Returns:
a new comparator
See Also:
Option.getTriggers()

preferredNameFirst

public static Comparator preferredNameFirst()
Orders Options by preferredName

Returns:
a new comparator
See Also:
Option.getPreferredName()

preferredNameLast

public static Comparator preferredNameLast()
Orders Options by preferredName, reversed

Returns:
a new comparator
See Also:
Option.getPreferredName()

requiredFirst

public static Comparator requiredFirst()
Orders Options grouping required Options first

Returns:
a new comparator
See Also:
Option.isRequired()

requiredLast

public static Comparator requiredLast()
Orders Options grouping required Options last

Returns:
a new comparator
See Also:
Option.isRequired()