framework.Tuple Maven / Gradle / Ivy
package framework;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.BiFunction;
import java.util.function.Consumer;
/**
* Tuple
*
* @param Left type
* @param Right type
*/
public class Tuple implements Map.Entry {
/**
* left value
*/
public final L l;
/**
* right value
*/
public final R r;
/**
* @param l left value
* @param r right value
*/
protected Tuple(L l, R r) {
this.l = l;
this.r = r;
}
@Override
public L getKey() {
return l;
}
@Override
public R getValue() {
return r;
}
@Override
public R setValue(R value) {
throw new UnsupportedOperationException();
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
return Objects.hash(l, r);
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
if (obj instanceof Tuple) {
Tuple, ?> base = (Tuple, ?>) obj;
return Objects.equals(l, base.l) && Objects.equals(r, base.r);
}
return false;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return Objects.toString(l) + (r == null ? "" : ", " + Objects.toString(r));
}
/**
* @return List
*/
public List