org.planx.msd
Class Discriminators

java.lang.Object
  extended by org.planx.msd.Discriminators

public final class Discriminators
extends Object

Utility class that provides methods for common discriminator tasks.

Author:
Thomas Ambus

Constructor Summary
Discriminators()
           
 
Method Summary
static
<U,S,A,B> Collection<List<S>>
discriminate(List<? extends U> values, Discriminator<A> d1, Extractor<U,? extends A,U> e1, Discriminator<B> d2, Extractor<U,? extends B,S> e2)
           
static
<U,S,A,B,C>
Collection<List<S>>
discriminate(List<? extends U> values, Discriminator<A> d1, Extractor<U,? extends A,U> e1, Discriminator<B> d2, Extractor<U,? extends B,U> e2, Discriminator<C> d3, Extractor<U,? extends C,S> e3)
           
static
<U,S,A,B,C,D>
Collection<List<S>>
discriminate(List<? extends U> values, Discriminator<A> d1, Extractor<U,? extends A,U> e1, Discriminator<B> d2, Extractor<U,? extends B,U> e2, Discriminator<C> d3, Extractor<U,? extends C,U> e3, Discriminator<D> d4, Extractor<U,? extends D,S> e4)
           
static boolean equals(CharSequence c1, CharSequence c2)
          Efficient equivalence testing of two CharSequences.
static
<E> boolean
equals(E o1, E o2, Discriminator<E> d)
          Returns true if and only if o1 and o2 are equivalent under the equivalence defined by the specified Discriminator.
static
<T> Extractor<T,T,T>
identityExtractor()
          Returns an Extractor where the label and value are identical to the original value.
static
<U,T> Extractor<U,T,U>
identityExtractor(Extractor<U,T,?> e)
          Returns an Extractor where the label is extracted by the specified Extractor and the value is just the original value.
static
<T,S,P extends Pair<T,S>>
Extractor<P,T,S>
pairExtractor()
          Returns an Extractor that extracts the first component of a Pair as the label and the second component as the value.
static
<T,P extends Pair<T,?>>
Extractor<P,T,P>
pairFirstExtractor()
          Returns an Extractor that extracts the first component of a Pair as the label and the whole pair as the value.
static
<T,S,P extends Pair<T,S>>
Extractor<P,S,T>
pairFlipExtractor()
          Returns an Extractor that extracts the first component of a Pair as the value and the second component as the label.
static
<S,P extends Pair<?,S>>
Extractor<P,S,P>
pairSecondExtractor()
          Returns an Extractor that extracts the second component of a Pair as the label and the whole pair as the value.
static
<U,S> List<S>
valueList(List<? extends U> list, Extractor<U,?,S> e)
          Returns a List containing the values (as determined by the Extractor e) of the specified List.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Discriminators

public Discriminators()
Method Detail

equals

public static <E> boolean equals(E o1,
                                 E o2,
                                 Discriminator<E> d)
Returns true if and only if o1 and o2 are equivalent under the equivalence defined by the specified Discriminator.


equals

public static boolean equals(CharSequence c1,
                             CharSequence c2)
Efficient equivalence testing of two CharSequences. Equivalence on the CharSequences is defined as the standard equality, where two sequences are equal if and only if they have the same length and their elements are pair-wise equal.


identityExtractor

public static <T> Extractor<T,T,T> identityExtractor()
Returns an Extractor where the label and value are identical to the original value.


identityExtractor

public static <U,T> Extractor<U,T,U> identityExtractor(Extractor<U,T,?> e)
Returns an Extractor where the label is extracted by the specified Extractor and the value is just the original value.


pairExtractor

public static <T,S,P extends Pair<T,S>> Extractor<P,T,S> pairExtractor()
Returns an Extractor that extracts the first component of a Pair as the label and the second component as the value.


pairFlipExtractor

public static <T,S,P extends Pair<T,S>> Extractor<P,S,T> pairFlipExtractor()
Returns an Extractor that extracts the first component of a Pair as the value and the second component as the label.


pairFirstExtractor

public static <T,P extends Pair<T,?>> Extractor<P,T,P> pairFirstExtractor()
Returns an Extractor that extracts the first component of a Pair as the label and the whole pair as the value.


pairSecondExtractor

public static <S,P extends Pair<?,S>> Extractor<P,S,P> pairSecondExtractor()
Returns an Extractor that extracts the second component of a Pair as the label and the whole pair as the value.


valueList

public static <U,S> List<S> valueList(List<? extends U> list,
                                      Extractor<U,?,S> e)
Returns a List containing the values (as determined by the Extractor e) of the specified List.


discriminate

public static <U,S,A,B> Collection<List<S>> discriminate(List<? extends U> values,
                                                         Discriminator<A> d1,
                                                         Extractor<U,? extends A,U> e1,
                                                         Discriminator<B> d2,
                                                         Extractor<U,? extends B,S> e2)

discriminate

public static <U,S,A,B,C> Collection<List<S>> discriminate(List<? extends U> values,
                                                           Discriminator<A> d1,
                                                           Extractor<U,? extends A,U> e1,
                                                           Discriminator<B> d2,
                                                           Extractor<U,? extends B,U> e2,
                                                           Discriminator<C> d3,
                                                           Extractor<U,? extends C,S> e3)

discriminate

public static <U,S,A,B,C,D> Collection<List<S>> discriminate(List<? extends U> values,
                                                             Discriminator<A> d1,
                                                             Extractor<U,? extends A,U> e1,
                                                             Discriminator<B> d2,
                                                             Extractor<U,? extends B,U> e2,
                                                             Discriminator<C> d3,
                                                             Extractor<U,? extends C,U> e3,
                                                             Discriminator<D> d4,
                                                             Extractor<U,? extends D,S> e4)


Copyright © 2010. All Rights Reserved.