Class Value

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String INVISIBLE  
    • Constructor Summary

      Constructors 
      Constructor Description
      Value()
      Default constructor.
      Value​(java.lang.String prop)
      Constructor.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void addEquivalentKey​(java.lang.String other)
      Adds a moniker that is equivalent to the original property key used during construction.
      void addListener​(ValueListener listener)
      Listener for value changes.
      java.lang.String alias​(java.lang.String str)
      Alias the given setting.
      protected java.lang.String alias​(java.lang.String str, java.lang.String[] aliases, boolean nullNotFound)
      Alias the given setting.
      protected void assertChangeable()
      Asserts if this receiver can be changed.
      java.lang.Object clone()  
      boolean equals​(java.lang.Object other)
      Use original value instead of current value because they are one and the same for non-dynamic Values and ensures that modifying dynamic Values do not impact equality or hashCode contract.
      abstract java.lang.Object get()
      Get the actual data stored in this value.
      java.lang.String[] getAliases()
      Aliases for the value in the form key1, value1, key2, value2, ...
      java.lang.String getDefault()
      The default value for the property as a string.
      java.util.Set<java.lang.String> getEquivalentKeys()
      Gets the unmodifiable view of the equivalent keys or an empty set if no equivalent key has been added.
      java.lang.String getInstantiatingGetter()
      The name of the getter method for the instantiated value of this property(as opposed to the string value)
      protected abstract java.lang.String getInternalString()
      Return the internal string form of this value.
      java.util.List<ValueListener> getListeners()
      Gets unmodifable list of listeners for value changes.
      java.lang.String getLoadKey()
      The key under which this value was loaded, or null.
      java.lang.String getOriginalValue()
      Gets the original value.
      java.lang.String getProperty()
      The property name that will be used when setting or getting this value in a Map.
      java.util.List<java.lang.String> getPropertyKeys()
      Gets unmodifiable view of all the property keys set on this receiver.
      java.lang.Class getScope()
      A class defining the scope in which this value is defined.
      java.lang.String getString()
      Return a stringified version of this value.
      abstract java.lang.Class<?> getValueType()
      Returns the type of the property that this Value represents.
      int hashCode()
      Use original value instead of current value because they are one and the same for non-dynamic Values and ensures that modifying dynamic Values do not impact equality or hashCode contract.
      void hide()
      Hides the value of this Value from being output to the caller.
      boolean isAliasListComprehensive()
      Whether or not the alias list defines all possible settings for this value.
      boolean isDynamic()
      Affirms if this receiver can be mutated even when the configuration it belongs to has been frozen.
      boolean isHidden()
      Affirms if the value for this Value is visible.
      boolean isPrivate()
      Affirms if this Value is used for internal purpose only and not exposed as a supported property.
      void makePrivate()
      Marks this Value for internal purpose only.
      boolean matches​(java.lang.String p)
      Affirms if the given key matches the property (or any of its equivalent).
      void removeListener​(ValueListener listener)  
      void setAlias​(java.lang.String key, java.lang.String value)
      Replaces an existing alias, or adds the given alias to the front of the alias list if it does not already exist.
      protected java.lang.String[] setAlias​(java.lang.String key, java.lang.String value, java.lang.String[] aliases)
      Set an alias into a current alias list, returning the new list.
      void setAliases​(java.lang.String[] aliases)
      Aliases for the value in the form key1, value1, key2, value2, ...
      void setAliasListComprehensive​(boolean aliasListIsComprehensive)
      Whether or not the alias list defines all possible settings for this value.
      void setDefault​(java.lang.String def)
      The default value for the property as a string.
      void setDynamic​(boolean flag)
      Sets if this receiver can be mutated even when the configuration it belongs to has been frozen.
      void setInstantiatingGetter​(java.lang.String getter)
      The name of the getter method for the instantiated value of this property(as opposed to the string value).
      protected abstract void setInternalObject​(java.lang.Object obj)
      Set this value from an object.
      protected abstract void setInternalString​(java.lang.String str)
      Set this value from the given string.
      void setLoadKey​(java.lang.String key)
      Sets key under which this value was loaded.
      void setObject​(java.lang.Object obj)
      Set this value as an object.
      void setProperty​(java.lang.String prop)
      The property name that will be used when setting or getting this value in a Map.
      void setScope​(java.lang.Class cls)
      A class defining the scope in which this value is defined.
      void setString​(java.lang.String val)
      Set this value from the given string.
      java.lang.String toString()  
      java.lang.String unalias​(java.lang.String str)
      Unalias the given setting.
      protected java.lang.String unalias​(java.lang.String str, java.lang.String[] aliases, boolean nullNotFound)
      Unalias the given setting.
      void valueChanged()
      Subclasses should call this method when their internal value changes.
      • Methods inherited from class java.lang.Object

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

      • Value

        public Value()
        Default constructor.
    • Method Detail

      • getProperty

        public java.lang.String getProperty()
        The property name that will be used when setting or getting this value in a Map.
      • setProperty

        public void setProperty​(java.lang.String prop)
        The property name that will be used when setting or getting this value in a Map.
      • addEquivalentKey

        public void addEquivalentKey​(java.lang.String other)
        Adds a moniker that is equivalent to the original property key used during construction.
        Since:
        2.0.0
      • getEquivalentKeys

        public java.util.Set<java.lang.String> getEquivalentKeys()
        Gets the unmodifiable view of the equivalent keys or an empty set if no equivalent key has been added.
        Since:
        2.0.0
      • getPropertyKeys

        public java.util.List<java.lang.String> getPropertyKeys()
        Gets unmodifiable view of all the property keys set on this receiver. The 0-th element in the returned list is always the same as the original key returned by getProperty() method.
        Since:
        2.0.0
      • matches

        public boolean matches​(java.lang.String p)
        Affirms if the given key matches the property (or any of its equivalent).
        Since:
        2.0.0
      • getLoadKey

        public java.lang.String getLoadKey()
        The key under which this value was loaded, or null.
      • setLoadKey

        public void setLoadKey​(java.lang.String key)
        Sets key under which this value was loaded.
      • getAliases

        public java.lang.String[] getAliases()
        Aliases for the value in the form key1, value1, key2, value2, ... All alias values must be in string form.
      • setAliases

        public void setAliases​(java.lang.String[] aliases)
        Aliases for the value in the form key1, value1, key2, value2, ... All alias values must be in string form.

        To avoid potential side-effects, this method copies the array passed in.

      • setAlias

        public void setAlias​(java.lang.String key,
                             java.lang.String value)
        Replaces an existing alias, or adds the given alias to the front of the alias list if it does not already exist. All alias values must be in string form.
      • setAlias

        protected java.lang.String[] setAlias​(java.lang.String key,
                                              java.lang.String value,
                                              java.lang.String[] aliases)
        Set an alias into a current alias list, returning the new list.
      • isAliasListComprehensive

        public boolean isAliasListComprehensive()
        Whether or not the alias list defines all possible settings for this value. If so, an error will be generated when attempting to invoke any method on this value with an unknown option.
      • setAliasListComprehensive

        public void setAliasListComprehensive​(boolean aliasListIsComprehensive)
        Whether or not the alias list defines all possible settings for this value. If so, an error will be generated when attempting to invoke any method on this value with an unknown option.
      • alias

        public java.lang.String alias​(java.lang.String str)
        Alias the given setting.
      • alias

        protected java.lang.String alias​(java.lang.String str,
                                         java.lang.String[] aliases,
                                         boolean nullNotFound)
        Alias the given setting.
      • unalias

        public java.lang.String unalias​(java.lang.String str)
        Unalias the given setting.
      • unalias

        protected java.lang.String unalias​(java.lang.String str,
                                           java.lang.String[] aliases,
                                           boolean nullNotFound)
        Unalias the given setting.
      • getDefault

        public java.lang.String getDefault()
        The default value for the property as a string.
      • setDefault

        public void setDefault​(java.lang.String def)
        The default value for the property as a string.
      • getInstantiatingGetter

        public java.lang.String getInstantiatingGetter()
        The name of the getter method for the instantiated value of this property(as opposed to the string value)
      • setInstantiatingGetter

        public void setInstantiatingGetter​(java.lang.String getter)
        The name of the getter method for the instantiated value of this property(as opposed to the string value). If the string starts with this., then the getter will be looked up on the value instance itself. Otherwise, the getter will be looked up on the configuration instance.
      • getScope

        public java.lang.Class getScope()
        A class defining the scope in which this value is defined. This will be used by the configuration framework to look up metadata about the value.
      • setScope

        public void setScope​(java.lang.Class cls)
        A class defining the scope in which this value is defined. This will be used by the configuration framework to look up metadata about the value.
      • getString

        public java.lang.String getString()
        Return a stringified version of this value. If the current value has a short alias key, the alias key is returned.
      • setString

        public void setString​(java.lang.String val)
        Set this value from the given string. If the given string is null or empty and a default is defined, the default is used. If the given string(or default) is an alias key, it will be converted to the corresponding value internally.
        If this Value is being set to a non-default value for the first time (as designated by originalString being null), then the value is remembered as original. This original value is used for equality and hashCode computation if this Value is dynamic.
      • setObject

        public void setObject​(java.lang.Object obj)
        Set this value as an object.
        If this Value is being set to a non-default value for the first time (as designated by originalString being null), then the value is remembered as original. This original value is used for equality and hashCode computation if this Value is dynamic.
      • getOriginalValue

        public java.lang.String getOriginalValue()
        Gets the original value. Original value denotes the Stringified form of this Value, from which it has been set, if ever. If this Value has never been set to a non-default value, then returns the default value, which itself can be null.
        Since:
        1.1.0
      • getValueType

        public abstract java.lang.Class<?> getValueType()
        Returns the type of the property that this Value represents.
      • getInternalString

        protected abstract java.lang.String getInternalString()
        Return the internal string form of this value.
      • setInternalString

        protected abstract void setInternalString​(java.lang.String str)
        Set this value from the given string.
      • setInternalObject

        protected abstract void setInternalObject​(java.lang.Object obj)
        Set this value from an object.
      • getListeners

        public java.util.List<ValueListener> getListeners()
        Gets unmodifable list of listeners for value changes.
      • addListener

        public void addListener​(ValueListener listener)
        Listener for value changes.
      • removeListener

        public void removeListener​(ValueListener listener)
      • valueChanged

        public void valueChanged()
        Subclasses should call this method when their internal value changes.
      • assertChangeable

        protected void assertChangeable()
        Asserts if this receiver can be changed. Subclasses must invoke this method before changing its internal state. This receiver can not be changed if all of the following is true
      • this receiver is not dynamic
      • ValueListener attached to this receiver is a Configuration
      • Configuration is read-only