You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
154 lines
1.7 KiB
154 lines
1.7 KiB
package com.porcupine.struct;
|
|
|
|
|
|
import com.porcupine.math.Calc;
|
|
|
|
|
|
/**
|
|
* Structure of 2 objects.
|
|
*
|
|
* @author Ondřej Hruška (MightyPork)
|
|
* @copy (c) 2012
|
|
* @param <T1> 1st object class
|
|
* @param <T2> 2nd object class
|
|
*/
|
|
public class Struct2<T1, T2> {
|
|
|
|
/**
|
|
* 1st object
|
|
*/
|
|
public T1 a;
|
|
|
|
/**
|
|
* 2nd object
|
|
*/
|
|
public T2 b;
|
|
|
|
|
|
/**
|
|
* Make structure of 2 objects
|
|
*
|
|
* @param objA 1st object
|
|
* @param objB 2nd object
|
|
*/
|
|
public Struct2(T1 objA, T2 objB) {
|
|
a = objA;
|
|
b = objB;
|
|
}
|
|
|
|
|
|
/**
|
|
* @return 1st object
|
|
*/
|
|
public T1 getA()
|
|
{
|
|
return a;
|
|
}
|
|
|
|
|
|
/**
|
|
* @return 2nd object
|
|
*/
|
|
public T2 getB()
|
|
{
|
|
return b;
|
|
}
|
|
|
|
|
|
/**
|
|
* @return 1st object
|
|
*/
|
|
public T1 get1()
|
|
{
|
|
return a;
|
|
}
|
|
|
|
|
|
/**
|
|
* @return 2nd object
|
|
*/
|
|
public T2 get2()
|
|
{
|
|
return b;
|
|
}
|
|
|
|
|
|
/**
|
|
* Set 1st object
|
|
*
|
|
* @param obj 1st object
|
|
*/
|
|
public void setA(T1 obj)
|
|
{
|
|
a = obj;
|
|
}
|
|
|
|
|
|
/**
|
|
* Set 2nd object
|
|
*
|
|
* @param obj 2nd object
|
|
*/
|
|
public void setB(T2 obj)
|
|
{
|
|
b = obj;
|
|
}
|
|
|
|
|
|
/**
|
|
* Set 1st object
|
|
*
|
|
* @param obj 1st object
|
|
*/
|
|
public void set1(T1 obj)
|
|
{
|
|
a = obj;
|
|
}
|
|
|
|
|
|
/**
|
|
* Set 2nd object
|
|
*
|
|
* @param obj 2nd object
|
|
*/
|
|
public void set2(T2 obj)
|
|
{
|
|
b = obj;
|
|
}
|
|
|
|
|
|
@Override
|
|
public boolean equals(Object obj)
|
|
{
|
|
if (obj == null) {
|
|
return false;
|
|
}
|
|
|
|
if (!this.getClass().equals(obj.getClass())) {
|
|
return false;
|
|
}
|
|
|
|
Struct2<?, ?> t = (Struct2<?, ?>) obj;
|
|
|
|
return Calc.areObjectsEqual(a, t.a) && Calc.areObjectsEqual(b, t.b);
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
public int hashCode()
|
|
{
|
|
int hash = 0;
|
|
hash += (a == null ? 0 : a.hashCode());
|
|
hash += (b == null ? 0 : b.hashCode());
|
|
return hash;
|
|
}
|
|
|
|
|
|
@Override
|
|
public String toString()
|
|
{
|
|
return "STRUCT {" + a + "," + b + "}";
|
|
}
|
|
|
|
}
|
|
|