net.sf.jagg.msd
Class ChainedDiscriminator<T>
java.lang.Object
net.sf.jagg.msd.AbstractDiscriminator<T>
net.sf.jagg.msd.ChainedDiscriminator<T>
- All Implemented Interfaces:
- Discriminator<T>
- Direct Known Subclasses:
- ArrayDiscriminator, CalendarDiscriminator, ClassDiscriminator, CollectionDiscriminator, DateDiscriminator, EnumDiscriminator, PropertiesDiscriminator, RandomAccessListDiscriminator
public abstract class ChainedDiscriminator<T>
- extends AbstractDiscriminator<T>
A ChainedDiscriminator relies on another
Discriminator to perform its work in a separate step, after
this discriminator's work is done.
- Since:
- 0.5.0
- Author:
- Randy Gettman
|
Method Summary |
<E> java.util.List<java.util.List<E>> |
|
discriminate(java.util.List<E> elements,
Extractor<E,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 abstract
|
getChainedExtractor(java.util.List<E> elements,
Extractor<E,T> extractor)
Returns an Extractor that extracts a label of unknown type
from a label of type T, using the given
Extractor, which supplies labels of type T. |
protected abstract
|
getDiscriminator(java.util.List<E> elements,
ChainedExtractor<E,?,T> extractor,
int index)
Returns a Discriminator that discriminates on an unknown
type. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ChainedDiscriminator
public ChainedDiscriminator()
discriminate
public <E> java.util.List<java.util.List<E>> discriminate(java.util.List<E> elements,
Extractor<E,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.
- 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. If for any reason, this is unable
to discriminate the List, e.g. the elements are non-
Discriminable objects, then this returns
null.
getChainedExtractor
protected abstract <E> ChainedExtractor<E,?,T> getChainedExtractor(java.util.List<E> elements,
Extractor<E,T> extractor)
- Returns an
Extractor that extracts a label of unknown type
from a label of type T, using the given
Extractor, which supplies labels of type T.
For the same index, the returned Extractor must return
labels of the same type as the type discriminated by the
Discriminator returned by getDiscriminator.
- Type Parameters:
E - The type of element.- Parameters:
elements - The List of elements.extractor - The Extractor that extracts a label of type
T from the element.
- Returns:
- A
ChainedExtractor that extracts a label of unknown
type from a label of type T. - See Also:
getDiscriminator(java.util.List, net.sf.jagg.msd.ChainedExtractor, int)
getDiscriminator
protected abstract <E> Discriminator<?> getDiscriminator(java.util.List<E> elements,
ChainedExtractor<E,?,T> extractor,
int index)
- Returns a
Discriminator that discriminates on an unknown
type. For the same index, the returned Discriminator must
discriminate on the same type as the labels that are returned by the
ChainedExtractor that is returned by
getChainedExtractor. If it is known that no more loops are
necessary, then the returned Discriminator may be
null.
- Parameters:
elements - The list of elements.extractor - The ChainedExtractor that was obtained from
getChainedExtractor.index - The index of the loop.
- Returns:
- A
Discriminator, or null if it is known
for sure that no more loops are necessary. - See Also:
getChainedExtractor(java.util.List, net.sf.jagg.msd.Extractor)
Copyright © 2010-2012 jAgg Team. All Rights Reserved.