Class SelectionPredicate<U>
java.lang.Object
space.arim.libertybans.api.select.SelectionPredicate<U>
- Type Parameters:
U- the type of the criterion
How a certain criterion can be used to exclude punishments from a
For most use cases, the static factory methods can be used to create instances. For advanced uses, it is also possible to extend this class directly; implementors must ensure that returned
SelectionOrder. For most use cases, the static factory methods can be used to create instances. For advanced uses, it is also possible to extend this class directly; implementors must ensure that returned
Sets are immutable and thread safe.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionValues accepted in the selection.final booleanA selection predicate is equal to another if and only ifacceptedValues()andrejectedValues()are equalfinal inthashCode()final booleanConvenience method which is the opposite ofisSimpleEquality()final booleanConvenience method to determine whetheracceptedValues()is a single value andrejectedValues()is emptystatic <U> SelectionPredicate<U> Creates a seletion predicate which matches anything and everythingstatic <U> SelectionPredicate<U> matchingAnyOf(Set<U> values) Creates a selection predicate which matches the given accepted valuesstatic <U> SelectionPredicate<U> matchingAnyOf(U first, U... extra) Creates a selection predicate which matches the given accepted valuesstatic <U> SelectionPredicate<U> matchingNone(Set<U> values) Creates a selection predicate which rejects the given values and matches all other valuesstatic <U> SelectionPredicate<U> matchingNone(U... values) Creates a selection predicate which rejects the given values and matches all other valuesstatic <U> SelectionPredicate<U> matchingOnly(U value) Creates a selection predicate which matches only a single accepted valueValues rejected in the selection.
-
Constructor Details
-
SelectionPredicate
public SelectionPredicate()
-
-
Method Details
-
acceptedValues
Values accepted in the selection. Values other than the ones specified here will be implicitly rejected and thus will not appear in the selection.
To accept all values, use an empty set. The empty set accepts all.- Returns:
- the values accepted, or an empty set to accept all values
-
rejectedValues
-
isSimpleEquality
public final boolean isSimpleEquality()Convenience method to determine whetheracceptedValues()is a single value andrejectedValues()is empty- Returns:
- true if and only if this predicate checks only a single accepted value
-
isNotSimpleEquality
public final boolean isNotSimpleEquality()Convenience method which is the opposite ofisSimpleEquality()- Returns:
- false if and only if this predicate checks only a single accepted value
-
equals
A selection predicate is equal to another if and only ifacceptedValues()andrejectedValues()are equal -
hashCode
-
matchingAll
Creates a seletion predicate which matches anything and everything- Type Parameters:
U- the type of the criterion- Returns:
- the predicate
-
matchingOnly
Creates a selection predicate which matches only a single accepted value- Type Parameters:
U- the type of the criterion- Parameters:
value- the value to match- Returns:
- the predicate
-
matchingAnyOf
Creates a selection predicate which matches the given accepted values- Type Parameters:
U- the type of the criterion- Parameters:
first- the first value to matchextra- the other values to match- Returns:
- the predicate
-
matchingAnyOf
Creates a selection predicate which matches the given accepted values- Type Parameters:
U- the type of the criterion- Parameters:
values- the values to match. Must not be empty- Returns:
- the predicate
- Throws:
IllegalArgumentException- ifvaluesis empty
-
matchingNone
Creates a selection predicate which rejects the given values and matches all other values- Type Parameters:
U- the type of the criterion- Parameters:
values- the values to reject- Returns:
- the predicate
-
matchingNone
Creates a selection predicate which rejects the given values and matches all other values- Type Parameters:
U- the type of the criterion- Parameters:
values- the values to reject- Returns:
- the predicate
-