Class CommandModel


  • public abstract class CommandModel
    extends Object
    Model for an administrative command
    Author:
    Jerome Dochez
    • Constructor Detail

      • CommandModel

        public CommandModel()
    • Method Detail

      • getCommandName

        public abstract String getCommandName()
        Returns the command name as it is typed by the user.
        Returns:
        the command name
      • getLocalizedDescription

        public abstract String getLocalizedDescription()
        Returns a localized description for this command
        Returns:
        a localized displayable description
      • getUsageText

        public abstract String getUsageText()
        Returns a localized usage text for this command or null if the usage text should be generated from this model.
        Returns:
        the usage text
      • getModelFor

        public abstract CommandModel.ParamModel getModelFor​(String paramName)
        Returns the parameter model for a particular parameter
        Parameters:
        paramName - the requested parameter model name
        Returns:
        the parameter model if the command supports a parameter of the passed name or null if not.
      • getParametersNames

        public abstract Collection<String> getParametersNames()
        Returns a collection of parameter names supported by this admininstrative command
        Returns:
        all the command's paramter names.
      • getCommandClass

        public abstract Class<?> getCommandClass()
        Return the class that defines the command. Normally this will be the class that provides the implementation of the command, but for generic CRUD commands it might be the config class that defines the command. The command class is used to locate resources related to the command, e.g., the command's man page. If the command model isn't associated with a command class, null is returned.
        Returns:
        the command class, or null if none
      • isManagedJob

        public abstract boolean isManagedJob()
        This command is managed job. It is preferred to listen using SSE in case of remote execution.
        Returns:
        true only if command is @ManagedJob
      • getClusteringAttributes

        public abstract ExecuteOn getClusteringAttributes()
        Return the cluster parameters for this command or null if none are specified and defaults should be used.
        Returns:
        a ExecuteOn annotation instance or null
      • add

        public abstract void add​(CommandModel.ParamModel model)
        Add a ParamModel for this command
        Parameters:
        model - the new param model to be added
      • getParameters

        public Collection<CommandModel.ParamModel> getParameters()
        Returns a collection of parameter model for all the parameters supported by this command.
        Returns:
        the command's parameters models.
      • getParamName

        public static String getParamName​(Param param,
                                          AnnotatedElement annotated)
        Get the Param name. First it checks if the annotated Param includes a name, if not then it gets the name from the field. If the parameter is a password, add the prefix and change the name to upper case.
        Parameters:
        param - class annotation
        annotated - annotated field or method
        Returns:
        the name of the param
      • unknownOptionsAreOperands

        public boolean unknownOptionsAreOperands()
        Should an unknown option be considered an operand by asadmin?
        Returns:
        true if unknown options are operands.