net.sf.molae.pipe.sorted
Class Bound<T>

java.lang.Object
  extended by net.sf.molae.pipe.basic.ObjectProxy<B>
      extended by net.sf.molae.pipe.union.ObjectUnion<Object,T,Object>
          extended by net.sf.molae.pipe.union.Extendable<T>
              extended by net.sf.molae.pipe.sorted.Bound<T>

public class Bound<T>
extends Extendable<T>

Wrapper around a comparable that allows for infinities.

Since:
2.0

Nested Class Summary
 
Nested classes/interfaces inherited from class net.sf.molae.pipe.union.Extendable
Extendable.ExtendableTransformer<T>
 
Method Summary
static
<T,E extends T>
Comparator<Bound<E>>
comparatorWithInfinity(Comparator<T> base, Bound<E> negativeInfinity, Bound<E> positiveInfinity)
          Constructs a comparator that compares the values of T with the specified comparator, but also handles the specified infinities.
static
<T> Bound<T>
getNegativeInfinity()
          Create a new negative infinity of the desired type.
static
<T> Bound<T>
getPositiveInfinity()
          Create a new positive infinity of the desired type.
static
<T> Bound<T>
newInstance(T base)
          Creates a new bound at the specified value.
static
<T> TwoWayTransformer<T,Bound<T>>
toBoundTransformer()
          Returns a transformer that returns a new bound of the specified value.
static
<T> TwoWayTransformer<Bound<T>,T>
toValueTransformer()
          Returns a transformer that returns the value of a bound.
 
Methods inherited from class net.sf.molae.pipe.union.Extendable
getValue, toExtendableTransformer
 
Methods inherited from class net.sf.molae.pipe.union.ObjectUnion
getBase1, getBase2, isOfType1, newInstance1, newInstance2
 
Methods inherited from class net.sf.molae.pipe.basic.ObjectProxy
assertNotNull, equals, getBase, hashCode, toString, toVerboseString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

getNegativeInfinity

public static <T> Bound<T> getNegativeInfinity()
Create a new negative infinity of the desired type.

Returns:
an object of type Bound that is smaller than all elements of T.

getPositiveInfinity

public static <T> Bound<T> getPositiveInfinity()
Create a new positive infinity of the desired type.

Returns:
an object of type Bound that is greater than all elements of T.

newInstance

public static <T> Bound<T> newInstance(T base)
Creates a new bound at the specified value.

Parameters:
base - base value used for comparison.

comparatorWithInfinity

public static <T,E extends T> Comparator<Bound<E>> comparatorWithInfinity(Comparator<T> base,
                                                                          Bound<E> negativeInfinity,
                                                                          Bound<E> positiveInfinity)
Constructs a comparator that compares the values of T with the specified comparator, but also handles the specified infinities.

Returns:
a new comparator with infinities
See Also:
ComparatorWithInfinity

toValueTransformer

public static <T> TwoWayTransformer<Bound<T>,T> toValueTransformer()
Returns a transformer that returns the value of a bound.

Returns:
a transformer that returns the value of a bound.

toBoundTransformer

public static <T> TwoWayTransformer<T,Bound<T>> toBoundTransformer()
Returns a transformer that returns a new bound of the specified value.

Returns:
a transformer that returns a new bound of the specified value.