Class RestrictionChainElement
- java.lang.Object
-
- net.kautler.command.api.restriction.RestrictionChainElement
-
public class RestrictionChainElement extends Object
A restriction chain element that can check a given restriction or combine different restrictions with boolean logic.
-
-
Constructor Summary
Constructors Constructor Description RestrictionChainElement(Class<? extends Restriction<?>> restriction)
Constructs a new restriction chain element for the given restriction class.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RestrictionChainElement
and(RestrictionChainElement other)
Returns a restriction chain element that combines this restriction chain element with the given one using boolean short-circuit "and" logic.<M> boolean
isCommandAllowed(M message, net.kautler.command.restriction.RestrictionLookup<? super M> availableRestrictions)
Returns whether the command triggered by the given message should be allowed or not.RestrictionChainElement
negate()
Returns a restriction chain element that negates this restriction chain element.RestrictionChainElement
or(RestrictionChainElement other)
Returns a restriction chain element that combines this restriction chain element with the given one using boolean short-circuit "or" logic.String
toString()
-
-
-
Constructor Detail
-
RestrictionChainElement
public RestrictionChainElement(Class<? extends Restriction<?>> restriction)
Constructs a new restriction chain element for the given restriction class.- Parameters:
restriction
- the restriction to wrap
-
-
Method Detail
-
isCommandAllowed
public <M> boolean isCommandAllowed(M message, net.kautler.command.restriction.RestrictionLookup<? super M> availableRestrictions)
Returns whether the command triggered by the given message should be allowed or not.- Type Parameters:
M
- the class of the message- Parameters:
message
- the message that triggered the commandavailableRestrictions
- the look up to find the actual restriction implementations- Returns:
- whether the command triggered by the given message should be allowed or not
-
and
public RestrictionChainElement and(RestrictionChainElement other)
Returns a restriction chain element that combines this restriction chain element with the given one using boolean short-circuit "and" logic.- Parameters:
other
- the restriction chain element to be combined with this restriction chain element- Returns:
- a restriction chain element that represents the boolean combination
-
or
public RestrictionChainElement or(RestrictionChainElement other)
Returns a restriction chain element that combines this restriction chain element with the given one using boolean short-circuit "or" logic.- Parameters:
other
- the restriction chain element to be combined with this restriction chain element- Returns:
- a restriction chain element that represents the boolean combination
-
negate
public RestrictionChainElement negate()
Returns a restriction chain element that negates this restriction chain element.- Returns:
- a restriction chain element that negates this restriction chain element
-
-