Class AnyOf<M>
- java.lang.Object
-
- net.kautler.command.api.restriction.AnyOf<M>
-
- Type Parameters:
M- the class of the messages for which this restriction can check allowance
- All Implemented Interfaces:
Restriction<M>
public abstract class AnyOf<M> extends Object implements Restriction<M>
A restriction that checks multiple other restrictions one of which must allow a command. To use it, create a trivial subclass of this class and make it a discoverable CDI bean, for example by annotating it with@ApplicationScoped.Example:
@ApplicationScoped public class RoleAOrRoleB extends AnyOf<Message>{// make bean proxyable according to CDI spec public RoleAOrRoleB() { super(); }@Inject RoleAOrRoleB(RoleA roleA, RoleB roleB) { super(roleA, roleB); }}
-
-
Constructor Summary
Constructors Constructor Description AnyOf(Restriction<? super M>... restrictions)Constructs a new any-of restriction.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanallowCommand(CommandContext<? extends M> commandContext)Returns whether a command caused by the given command context should be allowed by this restriction or not.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.kautler.command.api.restriction.Restriction
getRealClass
-
-
-
-
Constructor Detail
-
AnyOf
@SafeVarargs public AnyOf(Restriction<? super M>... restrictions)
Constructs a new any-of restriction.- Parameters:
restrictions- the restrictions of which any one must allow a command
-
-
Method Detail
-
allowCommand
public boolean allowCommand(CommandContext<? extends M> commandContext)
Description copied from interface:RestrictionReturns whether a command caused by the given command context should be allowed by this restriction or not.- Specified by:
allowCommandin interfaceRestriction<M>- Parameters:
commandContext- the command context, usually fully populated- Returns:
- whether a command caused by the given command context should be allowed by this restriction or not
-
-