net.sf.jagg.msd
Class CollectionDiscriminator<T>

java.lang.Object
  extended by net.sf.jagg.msd.AbstractDiscriminator<T>
      extended by net.sf.jagg.msd.ChainedDiscriminator<java.util.Collection<T>>
          extended by net.sf.jagg.msd.CollectionDiscriminator<T>
All Implemented Interfaces:
Discriminator<java.util.Collection<T>>

public class CollectionDiscriminator<T>
extends ChainedDiscriminator<java.util.Collection<T>>

A CollectionDiscriminator discriminates Lists of Collections. The Collections are the items being discriminated.

Since:
0.5.0
Author:
Randy Gettman

Nested Class Summary
protected  class CollectionDiscriminator.CollectionChainedExtractor<E,B>
          A CollectionChainedExtractor turns Collections into RandomAccess Lists.
 
Constructor Summary
CollectionDiscriminator()
           
 
Method Summary
<E> java.util.List<java.util.List<E>>
discriminate(java.util.List<E> elements, Extractor<E,java.util.Collection<T>> extractor, MsdWorkspace workspace)
          Partitions the given List of elements into another List, in which all of the elements from the given list exist in the new list, and all elements that compare equal are adjacent to each other, according to the given Extractor.
protected
<E> ChainedExtractor<E,java.util.List<T>,java.util.Collection<T>>
getChainedExtractor(java.util.List<E> elements, Extractor<E,java.util.Collection<T>> extractor)
          Returns an appropriate ChainedExtractor.
protected
<E> Discriminator<T>
getDiscriminator(java.util.List<E> elements, ChainedExtractor<E,?,java.util.Collection<T>> extractor, int index)
          Returns the Discriminator that discriminates on the collection's base type.
 
Methods inherited from class net.sf.jagg.msd.AbstractDiscriminator
discriminate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CollectionDiscriminator

public CollectionDiscriminator()
Method Detail

discriminate

public <E> java.util.List<java.util.List<E>> discriminate(java.util.List<E> elements,
                                                          Extractor<E,java.util.Collection<T>> extractor,
                                                          MsdWorkspace workspace)
Partitions the given List of elements into another List, in which all of the elements from the given list exist in the new list, and all elements that compare equal are adjacent to each other, according to the given Extractor.

Specified by:
discriminate in interface Discriminator<java.util.Collection<T>>
Overrides:
discriminate in class ChainedDiscriminator<java.util.Collection<T>>
Type Parameters:
E - The type of element that is being discriminated by the type <E>
Parameters:
elements - A List of elements.
extractor - An Extractor that gives labels for each element.
workspace - The MsdWorkspace used in the discrimination process.
Returns:
A List of Lists containing all equivalence classes. Each equivalence class list contains all elements that compare equal to each other.

getChainedExtractor

protected <E> ChainedExtractor<E,java.util.List<T>,java.util.Collection<T>> getChainedExtractor(java.util.List<E> elements,
                                                                                                Extractor<E,java.util.Collection<T>> extractor)
Returns an appropriate ChainedExtractor.

Specified by:
getChainedExtractor in class ChainedDiscriminator<java.util.Collection<T>>
Type Parameters:
E - The type of element.
Parameters:
elements - The List of elements.
extractor - A ChainedExtractor that returns appropriate labels.
Returns:
An appropriate ChainedExtractor.
See Also:
ChainedDiscriminator.getDiscriminator(java.util.List, net.sf.jagg.msd.ChainedExtractor, int)

getDiscriminator

protected <E> Discriminator<T> getDiscriminator(java.util.List<E> elements,
                                                ChainedExtractor<E,?,java.util.Collection<T>> extractor,
                                                int index)
Returns the Discriminator that discriminates on the collection's base type.

Specified by:
getDiscriminator in class ChainedDiscriminator<java.util.Collection<T>>
Parameters:
elements - The list of elements.
extractor - The ChainedExtractor that was obtained from getChainedExtractor.
index - The index of the loop.
Returns:
A Discriminator that discriminates on the collection's base type.
See Also:
ChainedDiscriminator.getChainedExtractor(java.util.List, net.sf.jagg.msd.Extractor)


Copyright © 2010-2013 jAgg Team. All Rights Reserved.