Package org.javatuples
Class KeyValue<A,B>
- java.lang.Object
-
- org.javatuples.Tuple
-
- org.javatuples.KeyValue<A,B>
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Comparable<Tuple>,java.lang.Iterable<java.lang.Object>,IValueKey<A>,IValueValue<B>
public final class KeyValue<A,B> extends Tuple implements IValueKey<A>, IValueValue<B>
A tuple of two elements, with positions 0 and 1 renamed as "key" and "value", respectively.
- Since:
- 1.0
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <X> KeyValue<X,X>fromArray(X[] array)Create tuple from array.static <X> KeyValue<X,X>fromCollection(java.util.Collection<X> collection)static <X> KeyValue<X,X>fromIterable(java.lang.Iterable<X> iterable)static <X> KeyValue<X,X>fromIterable(java.lang.Iterable<X> iterable, int index)private static <X> KeyValue<X,X>fromIterable(java.lang.Iterable<X> iterable, int index, boolean exactSize)AgetKey()intgetSize()Return the size of the tuple.BgetValue()<X> KeyValue<X,B>setKey(X key)<Y> KeyValue<A,Y>setValue(Y value)static <A,B>
KeyValue<A,B>with(A key, B value)-
Methods inherited from class org.javatuples.Tuple
compareTo, contains, containsAll, containsAll, equals, getValue, hashCode, indexOf, iterator, lastIndexOf, toArray, toList, toString
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
SIZE
private static final int SIZE
- See Also:
- Constant Field Values
-
key
private final A key
-
value
private final B value
-
-
Method Detail
-
with
public static <A,B> KeyValue<A,B> with(A key, B value)
-
fromArray
public static <X> KeyValue<X,X> fromArray(X[] array)
Create tuple from array. Array has to have exactly two elements.
- Type Parameters:
X- the array component type- Parameters:
array- the array to be converted to a tuple- Returns:
- the tuple
-
fromCollection
public static <X> KeyValue<X,X> fromCollection(java.util.Collection<X> collection)
-
fromIterable
public static <X> KeyValue<X,X> fromIterable(java.lang.Iterable<X> iterable)
-
fromIterable
public static <X> KeyValue<X,X> fromIterable(java.lang.Iterable<X> iterable, int index)
-
fromIterable
private static <X> KeyValue<X,X> fromIterable(java.lang.Iterable<X> iterable, int index, boolean exactSize)
-
getValue
public B getValue()
- Specified by:
getValuein interfaceIValueValue<A>
-
getSize
public int getSize()
Description copied from class:TupleReturn the size of the tuple.
-
-