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 booleanallNotNull()check if all values are not nullbooleanallNull()check all are nullbooleananyIsNotNull()check if any of the two values is not nullbooleananyIsNull()check if any values are null<T> voidboth(Consumer<T> tripleEntryConsumer)Apply consumer all entries.Triple<A,B,C>copy()shallow copy of this triplebooleandifferent()Check if entries are not equalbooleanequals(Object other)Check equality to another tripleAfirst()Get first object in triplebooleanfirstNotNull()Check if first is non-nullObjectgetEarliestNonNull()inthashCode()static <A,B,C>
Triple<A,B,C>of(A valueA, B valueB, C valueC)Factory methodBsecond()Get second object in triplebooleansecondNotNull()Check if second is non-nullCthird()Get second object in triplebooleanthirdNotNull()Check if third is non-nullStringtoString()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:
hashCodein classObject- Returns:
- hashCode for this entity
- See Also:
Object.hashCode()
-
equals
public boolean equals(Object other)
Check equality to another triple- Overrides:
equalsin classObject- Parameters:
other- triple being compared to- See Also:
Object.equals(Object)
-
toString
public String toString()
Convert to string- Overrides:
toStringin 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
-
-