U
- Type of the pair's first element.V
- Type of the pair's second element.@PublicEvolving public abstract class Pair<U extends Key<U>,V extends Key<V>> extends Object implements Key<Pair<U,V>>
Key
,
Serialized FormConstructor and Description |
---|
Pair()
Initializes both encapsulated pair elements with empty objects.
|
Pair(U first,
V second)
Initializes the encapsulated pair elements with the provided values.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(Pair<U,V> o) |
boolean |
equals(Object obj)
Compares the object on equality with another object.
|
U |
getFirst()
Returns the first encapsulated pair element.
|
V |
getSecond()
Returns the second encapsulated pair element.
|
int |
hashCode()
All keys must override the hash-code function to generate proper deterministic hash codes,
based on their contents.
|
void |
read(DataInputView in)
Reads the object's internal data from the given data input view.
|
void |
setFirst(U first)
Sets the first encapsulated pair element to the specified value.
|
void |
setSecond(V second)
Sets the second encapsulated pair element to the specified value.
|
String |
toString() |
void |
write(DataOutputView out)
Writes the object's internal data to the given data output view.
|
public Pair()
public U getFirst()
public void setFirst(U first)
first
- The new value of the first encapsulated pair element.public V getSecond()
public void setSecond(V second)
second
- The new value of the second encapsulated pair element.public void read(DataInputView in) throws IOException
IOReadableWritable
read
in interface IOReadableWritable
in
- the input view to read the data fromIOException
- thrown if any error occurs while reading from the input streampublic void write(DataOutputView out) throws IOException
IOReadableWritable
write
in interface IOReadableWritable
out
- the output view to receive the data.IOException
- thrown if any error occurs while writing to the output streampublic int hashCode()
Key
Copyright © 2014–2017 The Apache Software Foundation. All rights reserved.