Package org.goplanit.utils.misc
Class Triple<A,B,C>
- java.lang.Object
-
- org.goplanit.utils.misc.Triple<A,B,C>
-
- Type Parameters:
A
- first object in tripleB
- second object in tripleC
- second object in triple
public class Triple<A,B,C> extends Object
Custom Triple class similar to Pair, only with three entries. value- Author:
- markr
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
allNotNull()
check if all values are not nullboolean
allNull()
check all are nullboolean
anyIsNotNull()
check if any of the two values is not nullboolean
anyIsNull()
check if any values are null<T> void
both(Consumer<T> tripleEntryConsumer)
Apply consumer all entries.Triple<A,B,C>
copy()
shallow copy of this tripleboolean
different()
Check if entries are not equalboolean
equals(Object other)
Check equality to another tripleA
first()
Get first object in tripleboolean
firstNotNull()
Check if first is non-nullObject
getEarliestNonNull()
int
hashCode()
static <A,B,C>
Triple<A,B,C>of(A valueA, B valueB, C valueC)
Factory methodB
second()
Get second object in tripleboolean
secondNotNull()
Check if second is non-nullC
third()
Get second object in tripleboolean
thirdNotNull()
Check if third is non-nullString
toString()
Convert to string
-
-
-
Method Detail
-
of
public static <A,B,C> Triple<A,B,C> of(A valueA, B valueB, C valueC)
Factory method- Type Parameters:
A
- type of valueAB
- type of valueBC
- type of valueC- Parameters:
valueA
- firstvalueB
- secondvalueC
- third- Returns:
- new triple
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classObject
- Returns:
- hashCode for this entity
- See Also:
Object.hashCode()
-
equals
public boolean equals(Object other)
Check equality to another triple- Overrides:
equals
in classObject
- Parameters:
other
- triple being compared to- See Also:
Object.equals(Object)
-
toString
public String toString()
Convert to string- Overrides:
toString
in classObject
- See Also:
Object.toString()
-
first
public A first()
Get first object in triple- Returns:
- first object in triple
-
second
public B second()
Get second object in triple- Returns:
- second object in triple
-
third
public C third()
Get second object in triple- Returns:
- second object in triple
-
anyIsNotNull
public boolean anyIsNotNull()
check if any of the two values is not null- Returns:
- true when one of the entries is not null
-
allNotNull
public boolean allNotNull()
check if all values are not null- Returns:
- true when both entries are not null
-
anyIsNull
public boolean anyIsNull()
check if any values are null- Returns:
- true when any are null, false otherwise
-
getEarliestNonNull
public Object getEarliestNonNull()
- Returns:
- earliest entry (first before second) that is nonNull, when both are null, null is returned
-
both
public <T> void both(Consumer<T> tripleEntryConsumer)
Apply consumer all entries. Throws ClassCastException when triple contains entries not compatible with type parameter of consumer- Type Parameters:
T
- consumer type assumed to be compatible with both triple entries- Parameters:
tripleEntryConsumer
- to apply
-
firstNotNull
public boolean firstNotNull()
Check if first is non-null- Returns:
- true when the case, false otherwise
-
secondNotNull
public boolean secondNotNull()
Check if second is non-null- Returns:
- true when the case, false otherwise
-
thirdNotNull
public boolean thirdNotNull()
Check if third is non-null- Returns:
- true when the case, false otherwise
-
different
public boolean different()
Check if entries are not equal- Returns:
- true when first does not equal second, false otherwise
-
allNull
public boolean allNull()
check all are null- Returns:
- true when both null, false otherwise
-
-