Package com.comphenix.protocol.utility
Class Optionals
java.lang.Object
com.comphenix.protocol.utility.Optionals
Utility methods for operating with Optionals
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> booleanCheck if the optional has a value and its value equals the provided valuestatic <T> Optional<T> Chains two optionals together by returning the secondary optional if the primary does not contain a valuestatic <T> booleanTestIfPresent(Optional<T> optional, Predicate<T> predicate) Evaluates the provided predicate against the optional only if it is present
-
Constructor Details
-
Optionals
public Optionals()
-
-
Method Details
-
or
Chains two optionals together by returning the secondary optional if the primary does not contain a value- Type Parameters:
T- Type- Parameters:
primary- Primary optionalsecondary- Supplier of secondary optional- Returns:
- The resulting optional
-
TestIfPresent
Evaluates the provided predicate against the optional only if it is present- Type Parameters:
T- Type- Parameters:
optional- Optionalpredicate- Test to run against potential value- Returns:
- True if the optional is present and the predicate passes
-
Equals
Check if the optional has a value and its value equals the provided value- Type Parameters:
T- Type- Parameters:
optional- Optionalcontents- Contents to test for- Returns:
- True if the optional has a value and that value equals the parameter
-