@Immutable public final class IdBox<T> extends java.lang.Object implements KeyedObject
A box that associates an object with an ID.
Constructor and Description |
---|
IdBox(long k,
T o)
Construct a new ID box.
|
Modifier and Type | Method and Description |
---|---|
static <T> IdBox<T> |
create(long id,
T obj)
Construct a new ID box.
|
boolean |
equals(java.lang.Object o) |
long |
getId()
Get the ID associated with the object.
|
long |
getKey()
Get the key for this object.
|
T |
getValue()
Get the value associated with the object.
|
int |
hashCode() |
<R> IdBox<R> |
mapValue(java.util.function.Function<? super T,? extends R> function)
Transform the value in a box.
|
java.lang.String |
toString() |
public IdBox(long k, T o)
Construct a new ID box.
k
- The ID.o
- The object.public static <T> IdBox<T> create(long id, T obj)
Construct a new ID box.
id
- The ID.obj
- The object.T
- The object type.obj
with id
.public long getId()
Get the ID associated with the object.
public long getKey()
KeyedObject
Get the key for this object.
getKey
in interface KeyedObject
public T getValue()
Get the value associated with the object.
public <R> IdBox<R> mapValue(java.util.function.Function<? super T,? extends R> function)
Transform the value in a box.
function
- The function to apply.R
- The function return type.public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object