Initial Commit
This commit is contained in:
55
src/main/java/net/locusworks/common/immutables/Pair.java
Normal file
55
src/main/java/net/locusworks/common/immutables/Pair.java
Normal file
@@ -0,0 +1,55 @@
|
||||
package net.locusworks.common.immutables;
|
||||
|
||||
/**
|
||||
* Class that holds two immutable objects as a pair
|
||||
* @author Isaac Parenteau
|
||||
* @version 1.0.0
|
||||
* @param <V1> class type of object 1
|
||||
* @param <V2> class type of object 2
|
||||
*/
|
||||
public class Pair<V1, V2> extends Unit<V1> {
|
||||
|
||||
private V2 value2;
|
||||
|
||||
/**
|
||||
* Constructor with no values
|
||||
*/
|
||||
public Pair() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param value1 Object 1
|
||||
* @param value2 Object 2
|
||||
*/
|
||||
public Pair(V1 value1, V2 value2) {
|
||||
super(value1);
|
||||
this.value2 = value2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set value2
|
||||
* @param value2 value to set it
|
||||
*/
|
||||
public void setValue2(V2 value2) {
|
||||
this.value2 = value2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get value2
|
||||
* @return value2
|
||||
*/
|
||||
public V2 getValue2() {
|
||||
return this.value2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (!(other instanceof Pair)) return false;
|
||||
|
||||
Pair<?, ?> otherPair = (Pair<?, ?>)other;
|
||||
|
||||
return super.equals(otherPair) && this.getValue2().equals(otherPair.getValue2());
|
||||
}
|
||||
}
|
||||
57
src/main/java/net/locusworks/common/immutables/Triplet.java
Normal file
57
src/main/java/net/locusworks/common/immutables/Triplet.java
Normal file
@@ -0,0 +1,57 @@
|
||||
package net.locusworks.common.immutables;
|
||||
|
||||
/**
|
||||
* Class that holds three immutable objects as triplets
|
||||
* @author Isaac Parenteau
|
||||
* @version 1.0.0
|
||||
* @param <V1> class type of object 1
|
||||
* @param <V2> class type of object 2
|
||||
* @param <V3> class type of object 3
|
||||
*/
|
||||
public class Triplet<V1, V2, V3> extends Pair<V1, V2> {
|
||||
|
||||
private V3 value3;
|
||||
|
||||
/**
|
||||
* default constructor with no values
|
||||
*/
|
||||
public Triplet() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param value1 Object 1
|
||||
* @param value2 Object 2
|
||||
* @param value3 Object 3
|
||||
*/
|
||||
public Triplet(V1 value1, V2 value2, V3 value3) {
|
||||
super(value1, value2);
|
||||
this.value3 = value3;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set value 3
|
||||
* @param value3 value 3
|
||||
*/
|
||||
public void setValue3(V3 value3) {
|
||||
this.value3 = value3;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get value 3
|
||||
* @return value 3
|
||||
*/
|
||||
public V3 getValue3() {
|
||||
return value3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (!(other instanceof Triplet)) return false;
|
||||
|
||||
Triplet<?, ?, ?> otherTriplet = (Triplet<?, ?, ?>)other;
|
||||
|
||||
return super.equals(otherTriplet) && this.getValue3().equals(otherTriplet.getValue3());
|
||||
}
|
||||
}
|
||||
50
src/main/java/net/locusworks/common/immutables/Unit.java
Normal file
50
src/main/java/net/locusworks/common/immutables/Unit.java
Normal file
@@ -0,0 +1,50 @@
|
||||
package net.locusworks.common.immutables;
|
||||
|
||||
/**
|
||||
* Class that holds three immutable objects as triplets
|
||||
* @author Isaac Parenteau
|
||||
* @version 1.0.0
|
||||
* @param <V1> class type of object 1
|
||||
*/
|
||||
public class Unit<V1> {
|
||||
|
||||
private V1 value1;
|
||||
|
||||
/**
|
||||
* Default constructor with no values
|
||||
*/
|
||||
public Unit() {}
|
||||
|
||||
/**
|
||||
* Constuctor
|
||||
* @param value1 value 1
|
||||
*/
|
||||
public Unit(V1 value1) {
|
||||
this.value1 = value1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set value 1
|
||||
* @param value1 value 1
|
||||
*/
|
||||
public void setValue1(V1 value1) {
|
||||
this.value1 = value1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get value 1
|
||||
* @return value1
|
||||
*/
|
||||
public V1 getValue1() {
|
||||
return value1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (!(other instanceof Unit)) return false;
|
||||
|
||||
Unit<?> otherUnit = (Unit<?>)other;
|
||||
|
||||
return this.getValue1().equals(otherUnit.getValue1());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user