Couple and Triple minor cleanup.

This commit is contained in:
Olof Larsson 2016-08-24 09:12:34 +02:00
parent b847737de8
commit 51eee0e247
No known key found for this signature in database
GPG Key ID: BBEF14F97DA52474
2 changed files with 18 additions and 13 deletions

View File

@ -18,10 +18,10 @@ public class Couple<A, B> implements Entry<A, B>, Cloneable, Serializable
// -------------------------------------------- // // -------------------------------------------- //
private final A first; private final A first;
public A getFirst() { return this.first; }; public A getFirst() { return this.first; }
private final B second; private final B second;
public B getSecond() { return this.second; }; public B getSecond() { return this.second; }
// -------------------------------------------- // // -------------------------------------------- //
// FIELDS: WITH // FIELDS: WITH
@ -63,7 +63,7 @@ public class Couple<A, B> implements Entry<A, B>, Cloneable, Serializable
} }
@Override @Override
public B setValue(B arg0) public B setValue(B value)
{ {
throw new IllegalStateException("This entry is a couple which is immutable."); throw new IllegalStateException("This entry is a couple which is immutable.");
} }
@ -82,12 +82,14 @@ public class Couple<A, B> implements Entry<A, B>, Cloneable, Serializable
// -------------------------------------------- // // -------------------------------------------- //
@Override @Override
public boolean equals(Object derpObject) public boolean equals(Object object)
{ {
if (derpObject == null) return false; if (!(object instanceof Couple<?, ?>)) return false;
if (!(derpObject instanceof Couple<?, ?>)) return false; Couple<?, ?> that = (Couple<?, ?>)object;
Couple<?, ?> derp = (Couple<?, ?>)derpObject; return MUtil.equals(
return MUtil.equals(this.getFirst(), derp.getFirst()) && MUtil.equals(this.getSecond(), derp.getSecond()); this.getFirst(), that.getFirst(),
this.getSecond(), that.getSecond()
);
} }
// -------------------------------------------- // // -------------------------------------------- //

View File

@ -63,12 +63,15 @@ public class Triple<A, B, C> implements Cloneable, Serializable
// -------------------------------------------- // // -------------------------------------------- //
@Override @Override
public boolean equals(Object derpObject) public boolean equals(Object object)
{ {
if (derpObject == null) return false; if (!(object instanceof Triple<?, ?, ?>)) return false;
if (!(derpObject instanceof Triple<?, ?, ?>)) return false; Triple<?, ?, ?> that = (Triple<?, ?, ?>)object;
Triple<?, ?, ?> derp = (Triple<?, ?, ?>)derpObject; return MUtil.equals(
return MUtil.equals(this.getFirst(), derp.getFirst()) && MUtil.equals(this.getSecond(), derp.getSecond()) && MUtil.equals(this.getThird(), derp.getThird()); this.getFirst(), that.getFirst(),
this.getSecond(), that.getSecond(),
this.getThird(), that.getThird()
);
} }
// -------------------------------------------- // // -------------------------------------------- //