org.planx.msd.util
Class DiscriminatorAdapter<T,E>

java.lang.Object
  extended by org.planx.msd.util.AbstractDiscriminator<T>
      extended by org.planx.msd.util.DiscriminatorAdapter<T,E>
All Implemented Interfaces:
Discriminator<T>

public abstract class DiscriminatorAdapter<T,E>
extends AbstractDiscriminator<T>

This class provides a skeletal implementation of a Discriminator that adapts its input to suit that of another Discriminator. The type arguments T and E corresponds to the type adapted from and the type adapted to, respectively. The implementation need only provide a transform(T) method.

Author:
Thomas Ambus

Constructor Summary
DiscriminatorAdapter(Discriminator<E> d)
          Constructs a new DiscriminatorAdapter which adapts its input to the specified Discriminator.
 
Method Summary
<U,S> Collection<List<S>>
discriminate(List<? extends U> values, Extractor<U,? extends T,S> e)
          Discriminates a List of values using an Extractor, and returns a Collection of Lists, each representing an equivalence class containing elements from values that are equivalent.
protected abstract  E transform(T value)
          Transform a value of the input type T to the type E expected as input to the wrapped Discriminator.
 
Methods inherited from class org.planx.msd.util.AbstractDiscriminator
discriminate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DiscriminatorAdapter

public DiscriminatorAdapter(Discriminator<E> d)
Constructs a new DiscriminatorAdapter which adapts its input to the specified Discriminator.

Method Detail

discriminate

public <U,S> Collection<List<S>> discriminate(List<? extends U> values,
                                              Extractor<U,? extends T,S> e)
Description copied from interface: Discriminator
Discriminates a List of values using an Extractor, and returns a Collection of Lists, each representing an equivalence class containing elements from values that are equivalent. The Extractor performs the task of extracting two kinds of objects from the input values: The label which is the object equivalence is defined upon, and the value which is the object that will be returned. That is, the label determines which equivalence class the value goes into.

The Collection of Lists returned should be considered unmodifiable (though, in some cases they might actually be modifiable, but this behaviour should not be relied upon).

Specified by:
discriminate in interface Discriminator<T>
Specified by:
discriminate in class AbstractDiscriminator<T>

transform

protected abstract E transform(T value)
Transform a value of the input type T to the type E expected as input to the wrapped Discriminator.



Copyright © 2010. All Rights Reserved.