Class Setting


  • @Equality
    public class Setting
    extends java.lang.Object
    Defines a key-value pair for use in a stilts command line. This representation focuses on the text values; there is not much in the way of type safety, which should be enforced if possible by earlier processing.

    The equality constraint is required to aid factorisation.

    Since:
    15 Sep 2017
    Author:
    Mark Taylor
    • Constructor Summary

      Constructors 
      Constructor Description
      Setting​(java.lang.String key, java.lang.String strValue, java.lang.String strDflt)
      Constructs a setting.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Setting appendSuffix​(java.lang.String suffix)
      Creates a new setting object which resembles this one, but whose parameter name is modified by addition of a given trailing string.
      boolean equals​(java.lang.Object o)  
      Credibility getCredibility()
      Returns the credibility of this setting.
      java.lang.String getKey()
      Returns this setting's parameter name.
      java.lang.Object getObjectValue()
      Returns the typed value for this setting, if known.
      java.lang.String getStringDefault()
      Returns the string representation of the default value for this setting.
      java.lang.String getStringValue()
      Returns the string representation of this setting's value.
      int hashCode()  
      boolean isDefaultValue()
      Indicates whether this setting's value is the same as the default value.
      Setting resetDefault​(java.lang.String strDflt)
      Creates a new setting object which resembles this one, except it has a different default value.
      void setCredibility​(Credibility cred)
      Sets the credibility of this setting.
      void setObjectValue​(java.lang.Object objValue)
      Sets the typed value associated with this setting.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Setting

        public Setting​(java.lang.String key,
                       java.lang.String strValue,
                       java.lang.String strDflt)
        Constructs a setting. The attributes set here are immutable and constitute the items used to assess equality.
        Parameters:
        key - stilts parameter name
        strValue - string representation of stilts parameter value; corresponds to actual value
        strDflt - string representation of stilts parameter default
    • Method Detail

      • getKey

        public java.lang.String getKey()
        Returns this setting's parameter name.
        Returns:
        key string
      • getStringValue

        public java.lang.String getStringValue()
        Returns the string representation of this setting's value.
        Returns:
        string value
      • getStringDefault

        public java.lang.String getStringDefault()
        Returns the string representation of the default value for this setting.
        Returns:
        default value
      • isDefaultValue

        public boolean isDefaultValue()
        Indicates whether this setting's value is the same as the default value. If so, for most purposes, specifying it has no effect.
        Returns:
        true iff this setting's value and default are equivalent
      • setObjectValue

        public void setObjectValue​(java.lang.Object objValue)
        Sets the typed value associated with this setting. This is optional, but if present gives to the typed value that the parameter would assume, corresponding to the string value.
        Parameters:
        objValue - typed value for setting
      • getObjectValue

        public java.lang.Object getObjectValue()
        Returns the typed value for this setting, if known.
        Returns:
        setting value as a typed object, or null if not known
      • setCredibility

        public void setCredibility​(Credibility cred)
        Sets the credibility of this setting. The default value is Credibility.YES.
        Parameters:
        cred - credibility level
      • getCredibility

        public Credibility getCredibility()
        Returns the credibility of this setting. The default value is Credibility.YES.
        Returns:
        credibility level
      • appendSuffix

        public Setting appendSuffix​(java.lang.String suffix)
        Creates a new setting object which resembles this one, but whose parameter name is modified by addition of a given trailing string.
        Parameters:
        suffix - string to append to parameter name
        Returns:
        new setting object with suffix
      • resetDefault

        public Setting resetDefault​(java.lang.String strDflt)
        Creates a new setting object which resembles this one, except it has a different default value.
        Parameters:
        strDflt - new default string
        Returns:
        new setting object with adjusted default
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object