Class AbstractArgumentOption

    • Field Detail

      • m_BaseClass

        protected Class m_BaseClass
        the base class.
      • m_Multiple

        protected boolean m_Multiple
        indicates whether the option can appear multiple times (for array properties).
      • m_Variable

        protected String m_Variable
        the variable placeholder.
      • m_VariableModified

        protected boolean m_VariableModified
        whether the variable got updated and needs propagating.
      • m_VariableReferencesObject

        protected Boolean m_VariableReferencesObject
        whether the variable references a global actor or storage.
    • Constructor Detail

      • AbstractArgumentOption

        protected AbstractArgumentOption​(OptionManager owner,
                                         String commandline,
                                         String property,
                                         Object defValue,
                                         UserMode minUserMode)
        Initializes the option. Always outputs the default value.
        Parameters:
        owner - the owner of this option
        commandline - the commandline string to identify the option (no leading dash)
        property - the name of bean property
        defValue - the default value, if null then the owner's current state is used
        minUserMode - the minimum user mode before showing this option
      • AbstractArgumentOption

        protected AbstractArgumentOption​(OptionManager owner,
                                         String commandline,
                                         String property,
                                         Object defValue,
                                         boolean outputDefValue,
                                         UserMode minUserMode)
        Initializes the option.
        Parameters:
        owner - the owner of this option
        commandline - the commandline string to identify the option (no leading dash)
        property - the name of bean property
        defValue - the default value, if null then the owner's current state is used
        outputDefValue - whether to output the default value or not
        minUserMode - the minimum user mode before showing this option
    • Method Detail

      • isMultiple

        public boolean isMultiple()
        Returns true if the option can appear multiple times (for array properties).
        Returns:
        true if the option can appear multiple times.
      • hasBaseClass

        public boolean hasBaseClass()
        Returns whether a base class could be determined.
        Returns:
        true if a base class is available
      • getBaseClass

        public Class getBaseClass()
        Returns the base class of this option. In case of arrays the class of the elements.
        Returns:
        the class
      • isVariableAttached

        public boolean isVariableAttached()
        Whether a variable has been attached to the option.
        Returns:
        true if a variable placeholder has been set
      • setVariable

        public String setVariable​(String value)
        Sets the variable placeholder to use, or null to disable.
        Parameters:
        value - the variable placeholder
        Returns:
        null if successfully set/unset, otherwise error message
      • getVariable

        public String getVariable()
        Returns the variable placeholder, if any.
        Returns:
        the variable placeholder, or null if none set
      • getVariableName

        public String getVariableName()
        Returns the variable name (without the surrounding "@{" and "}"), if any.
        Returns:
        the variable placeholder, or null if none set
      • isVariableModified

        public boolean isVariableModified()
        Returns whether the variable got updated in the meantime and needs propagating.
        Returns:
        true if the variable got updated
      • isVariableReferencingObject

        public boolean isVariableReferencingObject()
        Returns whether the variable points to a global actor or storage.
        Returns:
        true if the variable references a global actor or storage
      • updateVariable

        public String updateVariable()
        Updates the variable, i.e., retrieves the value for the variable and calls the read-method of this option to set it.
        Returns:
        null if successfully updated, otherwise error message
      • updateVariable

        public String updateVariable​(boolean silent)
        Updates the variable, i.e., retrieves the value for the variable and calls the read-method of this option to set it.
        Parameters:
        silent - whether to suppress error messages in the console
        Returns:
        null if successfully updated, otherwise error message
      • updateVariable

        public String updateVariable​(boolean silent,
                                     Logger log)
        Updates the variable, i.e., retrieves the value for the variable and calls the read-method of this option to set it.
        Parameters:
        silent - whether to suppress error messages in the console
        log - the logger to use for errors, can be null
        Returns:
        null if successfully updated, otherwise error message
      • valueOf

        public abstract Object valueOf​(String s)
                                throws Exception
        Turns the string into the appropriate object.
        Parameters:
        s - the string to parse
        Returns:
        the generated object
        Throws:
        Exception - if parsing of string fails
      • toString

        public abstract String toString​(Object obj)
        Returns a string representation of the specified object.
        Parameters:
        obj - the object to turn into a string
        Returns:
        the string representation
      • compareValues

        protected abstract boolean compareValues​(Object value,
                                                 Object defValue)
        Compares the two values.
        Parameters:
        value - the value to compare against the default value
        defValue - the default value to compare against
        Returns:
        true if both are equal
      • isDefaultValue

        public boolean isDefaultValue()
        Compares the current value against the default value.
        Returns:
        true if the value is the same as the default value
      • isDefaultValue

        protected boolean isDefaultValue​(Object value)
        Compares the given value against the default value.
        Parameters:
        value - the value to compare against the default value
        Returns:
        true if the value is the same as the default value
      • toArray

        public String[] toArray()
        Returns the current value of the option as string array.
        Returns:
        the array representation of the current value
      • toString

        public String toString()
        Returns the commandline option and the property as string.
        Overrides:
        toString in class Object
        Returns:
        the commandline option and property