H
- The type of the head item.T
- The fully qualified type of the tail Tuple
.public class Tuple<H,T extends Tuple<?,?>>
extends java.lang.Object
Constructor and Description |
---|
Tuple(H head,
T tail)
Create a Tuple instance with the given values for its head and tail
entries.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object other) |
H |
getHead()
Return the value of the head entry.
|
int |
getSize()
The number of entries in this tuple, including the head and every entry in
the tail.
|
T |
getTail()
Return the value of the tail entry.
|
boolean |
hasTail()
Does this tuple have a tail, or is it terminating.
|
<I> Tuple<I,T> |
mapHead(java.util.function.Function<? super H,? extends I> headMap)
Map the value of the head entry.
|
<U extends Tuple<?,?>> |
mapTail(java.util.function.Function<T,U> tailMap)
Map the value of the tail entry.
|
T |
next(H head) |
<P> Tuple<P,Tuple<H,T>> |
prepend(P prepend)
This method prepends the tuple with another tuple entry with the given
value, resulting in a tuple one extra in size.
|
void |
setHead(H head)
Set the value of the head entry.
|
void |
setTail(T tail)
Set the tuple entry which represents the tail of this tuple.
|
protected int |
tailCounter(int size) |
java.lang.String |
toString() |
protected java.lang.String |
toSubStrings() |
public H getHead()
public void setHead(H head)
head
- New head value. This parameter should be non-null.public <I> Tuple<I,T> mapHead(java.util.function.Function<? super H,? extends I> headMap)
I
- The type of the head of the new Tuple.headMap
- A mapping to a new head value. The result should be non-null.public <U extends Tuple<?,?>> Tuple<H,U> mapTail(java.util.function.Function<T,U> tailMap)
U
- The type of the tail of the new Tuple.tailMap
- A mapping to a new tail value. The result should be non-null.public T getTail()
public void setTail(T tail)
tail
- A new tuple of the exact expected type of the tail of this tuple.public boolean hasTail()
public int getSize()
protected int tailCounter(int size)
public <P> Tuple<P,Tuple<H,T>> prepend(P prepend)
P
- The type of the item to prepend.prepend
- The head value of the new tuple.public T next(H head)
head
- The value to set head with.next(Object)
such that every value can be set.public java.lang.String toString()
toString
in class java.lang.Object
protected java.lang.String toSubStrings()
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object