
com.github.simonharmonicminor.juu.collection.immutable.PairImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-useful-utils Show documentation
Show all versions of java-useful-utils Show documentation
Just some useful utils for everyday coding
package com.github.simonharmonicminor.juu.collection.immutable;
import java.io.Serializable;
import java.util.Objects;
import static com.github.simonharmonicminor.juu.collection.immutable.ImmutableCollectionUtils.pairEquals;
/**
* Simple implementation of {@link Pair}
*
* @param the type of the key
* @param the type of the value
* @see Serializable
* @since 1.0
*/
class PairImpl implements Pair, Serializable {
private final K key;
private final V value;
PairImpl(K key, V value) {
this.key = key;
this.value = value;
}
@Override
public K getKey() {
return key;
}
@Override
public V getValue() {
return value;
}
@Override
public boolean equals(Object o) {
return pairEquals(this, o);
}
@Override
public int hashCode() {
return Objects.hash(key, value);
}
@Override
public String toString() {
return String.format("(key=%s; value=%s)", key, value);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy