Module gomint.api

Class ParamValidator

    • Constructor Detail

      • ParamValidator

        public ParamValidator()
    • Method Detail

      • validate

        public abstract Object validate​(String input,
                                        CommandSender commandSender)
        Validates given input
        Parameters:
        input - from the command
        commandSender - which submitted the command
        Returns:
        non null object of validation on success (string for example) or null when validation failed
      • consume

        public abstract String consume​(Iterator<String> data)
        Consume all parts this validator needs as input from the command
        Parameters:
        data - left from the command which can be consumed
        Returns:
        the concatenated data consumed
      • getType

        public abstract ParamType getType()
        Get the type of this param.
        Returns:
        type of param
      • values

        public abstract List<String> values()
        Get the values when hasValues() is true.
        Returns:
        sorted list of values
      • hasValues

        public abstract boolean hasValues()
        Does this validator have values which should be sent with the command. This is mostly used by enum params which define a set of values for selection.
        Returns:
        true when there is data to be sent with this parameter, false when not
      • isOptional

        public boolean isOptional()
        Is this param optional?
        Returns:
        true when its optional, false when not
      • setOptional

        public void setOptional​(boolean optional)
        Set to optional
        Parameters:
        optional - true when this parameter is optional, false when not
      • getPostfix

        public String getPostfix()
        Get the attached postfix for this param validator
        Returns:
        postfix of this validator
      • setPostfix

        public void setPostfix​(String postfix)
        Set the postfix for this param validator. Postfixes are currently only supported on int validators, if set to something else it will be ignored.
        Parameters:
        postfix - which should be used
      • getHelpText

        public String getHelpText()
        Get a proper help text for the console output
        Returns:
        help text for the console