L - type of the left element.M - type of the middle element.R - type of the right element.public class Triple<L,M,R> extends Object implements Serializable, Emptily
The values of the triple can be mutable but the association, created by this class, among three instances cannot change.
The values of the triple are addressed as:
left, middle and right.
This implementation does't make any assumption
on the nature of the values.
There is an extension of Triple that
requires the provided values to be Comparable
and therefore is able to implement the Comparable
interface for itself.
This class implements Emptily.
A triple is considered to be empty if all
of its values are null.
| Modifier and Type | Field and Description |
|---|---|
protected L |
left
The
left element of the triple. |
protected M |
middle
The
middle element of the triple. |
protected R |
right
The
right element of the triple. |
| Modifier | Constructor and Description |
|---|---|
protected |
Triple()
Default constructor.
|
protected |
Triple(L left,
M middle,
R right)
Constructor with parameters.
|
| Modifier and Type | Method and Description |
|---|---|
static <L,M,R> Triple<L,M,R> |
empty()
Returns the singleton instance of an empty
Triple. |
boolean |
equals(Object other) |
L |
getLeft()
Returns the
left element of the triple. |
M |
getMiddle()
Returns the
middle element of the triple. |
R |
getRight()
Returns the
right element of the triple. |
int |
hashCode() |
boolean |
isEmpty()
Returns
true if this object is empty. |
static <L,M,R> Triple<L,M,R> |
of(L left,
M middle,
R right)
Creates a new
Triple with
the given values. |
String |
toString() |
protected final L left
left element of the triple.protected final M middle
middle element of the triple.protected final R right
right element of the triple.protected Triple()
This constructor is intended to be used by reflection during deserialization.
To create a new triple use the factory method.
protected Triple(L left, M middle, R right)
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.middle - the middle element of the triple.right - thr right element of the triple.public static <L,M,R> Triple<L,M,R> empty()
Triple.L - type of the left element.M - type of the middle element.R - type of the right element.Triple.public static <L,M,R> Triple<L,M,R> of(L left, M middle, R right)
Triple 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.middle - the middle element of the triple.right - thr right element of the triple.public boolean isEmpty()
true if this object is empty.public L getLeft()
left element of the triple.left element of the triple.public M getMiddle()
middle element of the triple.middle element of the triple.public R getRight()
right element of the triple.right element of the triple.Copyright © 2011–2020 Nerd4j. All rights reserved.