Class AllOf<M>

  • Type Parameters:
    M - the class of the messages for which this restriction can check allowance
    All Implemented Interfaces:
    Restriction<M>

    public abstract class AllOf<M>
    extends Object
    implements Restriction<M>
    A restriction that checks multiple other restrictions that must all 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 RoleAAndRoleB extends AllOf<Message> {
         // make bean proxyable according to CDI spec
         public RoleAAndRoleB() {
             super();
         }
    
         @Inject
         RoleAAndRoleB(RoleA roleA, RoleB roleB) {
             super(roleA, roleB);
         }
     }
     
    See Also:
    AnyOf, NoneOf
    • Constructor Detail

      • AllOf

        @SafeVarargs
        protected AllOf​(Restriction<? super M>... restrictions)
        Constructs a new all-of restriction.
        Parameters:
        restrictions - the restrictions that all must allow a command
    • Method Detail

      • allowCommand

        public boolean allowCommand​(CommandContext<? extends M> commandContext)
        Description copied from interface: Restriction
        Returns whether a command caused by the given command context should be allowed by this restriction or not.
        Specified by:
        allowCommand in interface Restriction<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