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 RestrictionChainElementand(Class<? extends Restriction<?>> other)Returns a restriction chain element that combines this restriction chain element with the given restriction class using boolean short-circuit "and" logic.RestrictionChainElementand(RestrictionChainElement other)Returns a restriction chain element that combines this restriction chain element with the given one using boolean short-circuit "and" logic.booleanequals(Object obj)inthashCode()<M> booleanisCommandAllowed(CommandContext<M> commandContext, Map<Class<?>,Restriction<? super M>> availableRestrictions)Returns whether the command triggered by the given command context should be allowed or not.RestrictionChainElementnegate()Returns a restriction chain element that negates this restriction chain element.RestrictionChainElementor(Class<? extends Restriction<?>> other)Returns a restriction chain element that combines this restriction chain element with the given restriction class using boolean short-circuit "or" logic.RestrictionChainElementor(RestrictionChainElement other)Returns a restriction chain element that combines this restriction chain element with the given one using boolean short-circuit "or" logic.StringtoString()
-
-
-
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(CommandContext<M> commandContext, Map<Class<?>,Restriction<? super M>> availableRestrictions)
Returns whether the command triggered by the given command context should be allowed or not.- Type Parameters:
M- the class of the message in the command context- Parameters:
commandContext- the command context, usually fully populatedavailableRestrictions- the lookup to find the actual restriction implementations- Returns:
- whether the command triggered by the given command context 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
-
and
public RestrictionChainElement and(Class<? extends Restriction<?>> other)
Returns a restriction chain element that combines this restriction chain element with the given restriction class using boolean short-circuit "and" logic.- Parameters:
other- the restriction class 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
-
or
public RestrictionChainElement or(Class<? extends Restriction<?>> other)
Returns a restriction chain element that combines this restriction chain element with the given restriction class using boolean short-circuit "or" logic.- Parameters:
other- the restriction class 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
-
-