Class RestrictionChainElement


  • public class RestrictionChainElement
    extends Object
    A restriction chain element that can check a given restriction or combine different restrictions with boolean logic.
    • 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 populated
        availableRestrictions - 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
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object