xapi.util.impl.AbstractPair Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of xapi-dev Show documentation
Show all versions of xapi-dev Show documentation
Everything needed to run a comprehensive dev environment.
Just type X_ and pick a service from autocomplete;
new dev modules will be added as they are built.
The only dev service not included in the uber jar is xapi-dev-maven,
as it includes all runtime dependencies of maven, adding ~4 seconds to build time,
and 6 megabytes to the final output jar size (without xapi-dev-maven, it's ~1MB).
The newest version!
package xapi.util.impl;
import java.util.Map.Entry;
import xapi.util.X_Util;
import xapi.util.api.Pair;
public class AbstractPair
implements Pair, Entry
{
public AbstractPair() {
}
public AbstractPair(X x,Y y) {
set0(x);
set1(y);
}
private X x;
private Y y;
@Override
public X get0() {
return x;
}
@Override
public Y get1() {
return y;
}
@Override
public void set0(X x) {
this.x=x;
}
@Override
public void set1(Y y) {
this.y=y;
}
@Override
public boolean equals(Object obj) {
if (obj == this)return true;
if (obj instanceof Pair){
Pair that = (Pair) obj;
if (X_Util.equal(x, that.get0())){
return X_Util.equal(y, that.get1());
}
}
if (obj instanceof Entry){
Entry that = (Entry) obj;
if (X_Util.equal(x, that.getKey())){
return X_Util.equal(y, that.getValue());
}
}
return false;
}
@Override
public int hashCode() {
int hash;
if (x == null)
hash = 0;
else{
hash = 37 * x.hashCode();
}
return hash + (y == null ? 0 : y.hashCode());
}
@Override
public String toString() {
return "["+get0()+" | "+get1()+"]";
}
@Override
public X getKey() {
return get0();
}
@Override
public Y getValue() {
return get1();
}
@Override
public Y setValue(Y value) {
try {
return get1();
} finally {
set1(value);
}
}
}