L - type of the left element.M - type of the middle element.R - type of the right element.public class ComparableTriple<L,M,R> extends Triple<L,M,R> implements Comparative<ComparableTriple<L,M,R>>
The values of the triple can be mutable but the relation, created by this class, among three instances cannot change.
The values of the triple are addressed as:
left, middle and right.
This class implements Comparable
so either the values are Comparable or a
suitable Comparator should be provided.
This class implements Emptily.
A triple is considered to be empty if both
of its values are null.
There are several factory methods that cover all the
most common use cases but, if you need to se up a custom
combination of comparable and non comparable
values, you can use the ComparableTriple.MiddleBuilder
amd ComparableTriple.FinalBuilder.
| Modifier and Type | Class and Description |
|---|---|
static class |
ComparableTriple.FinalBuilder<L,M>
Implementation of the
pattern builder intended to be used
to create ComparableTriples with custom combination of
comparable and non comparable values. |
static class |
ComparableTriple.MiddleBuilder<L>
Implementation of the
pattern builder intended to be used
to create ComparableTriples with custom combination of
comparable and non comparable values. |
| Modifier | Constructor and Description |
|---|---|
protected |
ComparableTriple(L left,
Comparator<L> leftComparator,
M middle,
Comparator<M> middleComparator,
R right,
Comparator<R> rightComparator)
Constructor with parameters.
|
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(ComparableTriple<L,M,R> other) |
static <L,M,R> ComparableTriple<L,M,R> |
empty()
Returns the singleton instance of an empty
ComparableTriple. |
Comparator<L> |
getLeftComparator()
Returns the comparator for values of type
<L>. |
Comparator<M> |
getMiddleComparator()
Returns the comparator for values of type
<M>. |
Comparator<R> |
getRightComparator()
Returns the comparator for values of type
<R>. |
static <L extends Comparable<L>,M extends Comparable<M>,R extends Comparable<R>> |
of(L left,
boolean leftNullLast,
M middle,
boolean middleNullLast,
R right,
boolean rightNullLast)
Creates a new
ComparableTriple with
the given values. |
static <L,M,R> ComparableTriple<L,M,R> |
of(L left,
Comparator<L> leftComparator,
M middle,
Comparator<M> middleComparator,
R right,
Comparator<R> rightComparator)
Creates a new
ComparableTriple with
the given values. |
static <L extends Comparable<L>,M extends Comparable<M>,R extends Comparable<R>> |
of(L left,
M middle,
R right)
Creates a new
ComparableTriple with
the given Comparable values. |
static <L extends Comparable<L>,M extends Comparable<M>,R extends Comparable<R>> |
of(Triple<L,M,R> triple)
Creates a new
ComparableTriple with
the given Comparable values. |
static <L extends Comparable<L>,M extends Comparable<M>,R extends Comparable<R>> |
of(Triple<L,M,R> triple,
boolean leftNullLast,
boolean middleNullLast,
boolean rightNullLast)
Creates a new
ComparableTriple starting
from the given Triple of Comparable
values and applies the given behavior for null
values. |
static <L,M,R> ComparableTriple<L,M,R> |
of(Triple<L,M,R> triple,
Comparator<L> leftComparator,
Comparator<M> middleComparator,
Comparator<R> rightComparator)
Creates a new
ComparableTriple starting
from the given Triple of Comparable
values and applies the given value comparators. |
static <L extends Comparable<L>> |
withLeft(L value)
Creates a new
ComparableTriple.MiddleBuilder with
the given left value. |
static <L extends Comparable<L>> |
withLeft(L value,
boolean nullLast)
Creates a new
ComparableTriple.MiddleBuilder with
the given left values. |
static <L> ComparableTriple.MiddleBuilder<L> |
withLeft(L value,
Comparator<L> comparator)
Creates a new
ComparableTriple.MiddleBuilder with
the given left values. |
equals, getLeft, getMiddle, getRight, hashCode, isEmpty, toStringprotected ComparableTriple(L left, Comparator<L> leftComparator, M middle, Comparator<M> middleComparator, R right, Comparator<R> rightComparator)
This constructor is intended to be used by extending classes only.
To create a new triple use the factory methods.
left - the left element of the triple.leftComparator - the Comparator for the left element.middle - the middle element of the triple.middleComparator - the Comparator for the middle element.right - the right element of the triple.rightComparator - the Comparator for the right element.public static <L,M,R> ComparableTriple<L,M,R> empty()
ComparableTriple.L - type of the element left.M - type of the element middle.R - type of the element right.ComparableTriple.public static <L extends Comparable<L>,M extends Comparable<M>,R extends Comparable<R>> ComparableTriple<L,M,R> of(L left, M middle, R right)
ComparableTriple with
the given Comparable values.
This implementation considers null to be
less than non-null. Using this method is
the same as invoking
ComparableTriple.of(left,false,middle,false,right,false).
L - type of the left element.M - type of the middle element.R - type of the right element.left - the left element of the triple.middle - the middle element of the triple.right - the right element of the triple.public static <L extends Comparable<L>,M extends Comparable<M>,R extends Comparable<R>> ComparableTriple<L,M,R> of(Triple<L,M,R> triple)
ComparableTriple with
the given Comparable values.
This implementation considers null to be
less than non-null. Using this method is
the same as invoking
ComparableTriple.of(left,false,middle,false,right,false).
This factory method is null-safe, if the
given triple is null, then this method will
return null.
L - type of the left element.M - type of the middle element.R - type of the right element.triple - the source triple to make Comparable.public static <L extends Comparable<L>,M extends Comparable<M>,R extends Comparable<R>> ComparableTriple<L,M,R> of(L left, boolean leftNullLast, M middle, boolean middleNullLast, R right, boolean rightNullLast)
ComparableTriple with
the given values.L - type of the left element.M - type of the middle element.R - type of the right element.left - the left element of the triple.leftNullLast - tells to consider null to be greater than non-null.middle - the middle element of the triple.middleNullLast - tells to consider null to be greater than non-null.right - the right element of the triple.rightNullLast - tells to consider null to be greater than non-null.public static <L extends Comparable<L>,M extends Comparable<M>,R extends Comparable<R>> ComparableTriple<L,M,R> of(Triple<L,M,R> triple, boolean leftNullLast, boolean middleNullLast, boolean rightNullLast)
ComparableTriple starting
from the given Triple of Comparable
values and applies the given behavior for null
values.
This factory method is null-safe, if the
given triple is null, then this method will
return null.
L - type of the left element.M - type of the middle element.R - type of the right element.triple - the source triple to make Comparable.leftNullLast - tells to consider null to be greater than non-null.middleNullLast - tells to consider null to be greater than non-null.rightNullLast - tells to consider null to be greater than non-null.public static <L,M,R> ComparableTriple<L,M,R> of(L left, Comparator<L> leftComparator, M middle, Comparator<M> middleComparator, R right, Comparator<R> rightComparator)
ComparableTriple with
the given values.L - type of the left element.M - type of the middle element.R - type of the right element.left - the left element of the triple.leftComparator - comparator for values of type <L>.middle - the middle element of the triple.middleComparator - comparator for values of type <M>.right - the right element of the triple.rightComparator - comparator for values of type <R>.public static <L,M,R> ComparableTriple<L,M,R> of(Triple<L,M,R> triple, Comparator<L> leftComparator, Comparator<M> middleComparator, Comparator<R> rightComparator)
ComparableTriple starting
from the given Triple of Comparable
values and applies the given value comparators.
This factory method is null-safe, if the
given triple is null, then this method will
return null.
L - type of the left element.M - type of the middle element.R - type of the right element.triple - the source triple to make Comparable.leftComparator - comparator for values of type <L>.middleComparator - comparator for values of type <M>.rightComparator - comparator for values of type <R>.public static <L extends Comparable<L>> ComparableTriple.MiddleBuilder<L> withLeft(L value)
ComparableTriple.MiddleBuilder with
the given left value.
This implementation considers null to be
less than non-null. Using this method is
the same as invoking
ComparableTriple.left(value,false).
L - type of the left element.value - the left element of the triple.ComparableTriple.MiddleBuilderpublic static <L extends Comparable<L>> ComparableTriple.MiddleBuilder<L> withLeft(L value, boolean nullLast)
ComparableTriple.MiddleBuilder with
the given left values.L - type of the left element.value - the left element of the triple.nullLast - tells to consider null to be greater than non-null.ComparableTriple.MiddleBuilderpublic static <L> ComparableTriple.MiddleBuilder<L> withLeft(L value, Comparator<L> comparator)
ComparableTriple.MiddleBuilder with
the given left values.L - type of the left element.value - the left element of the triple.comparator - comparator for values of type <L>.ComparableTriple.MiddleBuilderpublic int compareTo(ComparableTriple<L,M,R> other)
compareTo in interface Comparable<ComparableTriple<L,M,R>>public Comparator<L> getLeftComparator()
<L>.<L>.public Comparator<M> getMiddleComparator()
<M>.<M>.public Comparator<R> getRightComparator()
<R>.<R>.Copyright © 2011–2020 Nerd4j. All rights reserved.