|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.collections15.comparators.TransformingComparator<I,O>
public class TransformingComparator<I,O>
Decorates another Comparator
with transformation behavior. That
is, the input values are transformed, and the results are passed to the
underlying Comparator
's. compare
method.
Transformer
,
ComparableComparator
Field Summary | |
---|---|
protected java.util.Comparator<O> |
decorated
The decorated Comparator . |
protected Transformer<I,O> |
transformer
The Transformer being used. |
Constructor Summary | |
---|---|
protected |
TransformingComparator(Transformer<I,O> transformer,
java.util.Comparator<O> decorated)
Constructs an instance with the given Transformer and
Comparator . |
Method Summary | ||
---|---|---|
int |
compare(I obj1,
I obj2)
Returns the result of comparing the values from the transform operation. |
|
static
|
decorate(Transformer<I,O> transformer,
java.util.Comparator<O> decorated)
Returns an instance whose ordering is determined by applying the odereing of the specified Comparator to the output of the specified
Transformer . |
|
static
|
getInstance(Transformer<I,O> transformer)
Returns an instance whose ordering is based on the natural ordering of the output of the specified Transformer . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.util.Comparator |
---|
equals |
Field Detail |
---|
protected java.util.Comparator<O> decorated
Comparator
.
protected Transformer<I,O> transformer
Transformer
being used.
Constructor Detail |
---|
protected TransformingComparator(Transformer<I,O> transformer, java.util.Comparator<O> decorated)
Transformer
and
Comparator
.
transformer
- The Transformer
used to transform the
compared objects.decorated
- The decorated Comparator
that is applied
to the transformed comparison objects.
java.lang.IllegalArgumentException
- If either argument is null
.Method Detail |
---|
public static <I,O extends java.lang.Comparable> TransformingComparator<I,O> getInstance(Transformer<I,O> transformer)
Transformer
.
transformer
- The Transformer
used to transform the
compared objects prior to applying the natural sorting
order of the resulting transformed output.public static <I,O> TransformingComparator<I,O> decorate(Transformer<I,O> transformer, java.util.Comparator<O> decorated)
Comparator
to the output of the specified
Transformer
.
transformer
- The Transformer
used to transform the
compared objects.decorated
- The decorated Comparator
that is applied
to the transformed comparison objects.public int compare(I obj1, I obj2)
compare
in interface java.util.Comparator<I>
obj1
- The first object to transform then compare.obj2
- The second object to transform then compare.
obj1
is less than
obj2
. A positive value if obj1
is
greater than obj2
. Zero if the two objects are
equivalent with respect to the ordering.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |