Class JavaEnumSettingsDefinition<T extends java.lang.Enum<T>>

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.lang.String[] valueNames  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear​(Settings settings)
      Removes any values in the given settings object assocated with this settings definition
      void copySetting​(Settings srcSettings, Settings destSettings)
      Copies any setting value associated with this settings definition from the srcSettings settings to the destSettings.
      int getChoice​(Settings settings)
      Returns the current value for this settings
      T getDefaultEnum()
      Returns the Enum instance that is the default Enum for this SettingsDefinition.
      java.lang.String getDescription()
      Returns a description of this settings definition
      java.lang.String getDisplayChoice​(int value, Settings settings)
      Returns the String for the given enum value
      java.lang.String[] getDisplayChoices​(Settings settings)
      Gets the list of choices as strings based on the current settings
      T getEnumByOrdinal​(int ordinal)
      Returns the Enum instance that corresponds to the specified ordinal value.
      T getEnumValue​(Settings settings)
      Returns an enum instance that corresponds to the setting stored, or the default enum if the setting has not been assigned yet.
      T getEnumValue​(Settings settings, T defaultValueOverride)
      Returns an enum instance that corresponds to the setting stored, or the a custom default value if the setting has not been assigned yet.
      java.lang.String getName()
      Returns the name of this SettingsDefinition
      int getOrdinalByString​(java.lang.String stringValue)
      returns the Enum's ordinal using the Enum's string representation.
      java.lang.String getSettingName()
      The name of this setting as it is stored in a Settings object.
      boolean hasValue​(Settings setting)  
      void setChoice​(Settings settings, int value)
      Sets the given value into the settings object using this definition as a key
      void setEnumValue​(Settings settings, T enumValue)
      Sets the value of this SettingsDefinition using the ordinal of the specified enum.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • valueNames

        protected final java.lang.String[] valueNames
    • Constructor Detail

      • JavaEnumSettingsDefinition

        public JavaEnumSettingsDefinition​(java.lang.String settingName,
                                          java.lang.String name,
                                          java.lang.String description,
                                          T defaultValue)
        Parameters:
        settingName - String that specifies how this setting is stored
        name - Descriptive name of this setting
        description - Longer description
        defaultValue - Enum instance that will be returned when this SettingsDefinition has not been specified yet.
    • Method Detail

      • getDefaultEnum

        public T getDefaultEnum()
        Returns the Enum instance that is the default Enum for this SettingsDefinition.
        Returns:
        Enum
      • getEnumValue

        public T getEnumValue​(Settings settings)
        Returns an enum instance that corresponds to the setting stored, or the default enum if the setting has not been assigned yet.
        Parameters:
        settings - Settings object that stores the settings values.
        Returns:
        Enum<T> value, or getDefaultEnum() if not present.
      • getEnumValue

        public T getEnumValue​(Settings settings,
                              T defaultValueOverride)
        Returns an enum instance that corresponds to the setting stored, or the a custom default value if the setting has not been assigned yet.
        Parameters:
        settings - Settings object that stores the settings values.
        Returns:
        Enum<T> value, or the specified defaultValueOveride if not present.
      • setEnumValue

        public void setEnumValue​(Settings settings,
                                 T enumValue)
        Sets the value of this SettingsDefinition using the ordinal of the specified enum.
        Parameters:
        settings - Where SettingsDefinition values are stored.
        enumValue - Enum to store
      • getEnumByOrdinal

        public T getEnumByOrdinal​(int ordinal)
        Returns the Enum instance that corresponds to the specified ordinal value.
        Parameters:
        ordinal - integer that corresponds to an Enum.
        Returns:
        Enum
      • getOrdinalByString

        public int getOrdinalByString​(java.lang.String stringValue)
        returns the Enum's ordinal using the Enum's string representation.
        Parameters:
        stringValue - Enum's string rep
        Returns:
        integer index of the Enum
      • getSettingName

        public java.lang.String getSettingName()
        The name of this setting as it is stored in a Settings object.
        Returns:
        String name.
      • clear

        public void clear​(Settings settings)
        Description copied from interface: SettingsDefinition
        Removes any values in the given settings object assocated with this settings definition
        Specified by:
        clear in interface SettingsDefinition
        Parameters:
        settings - the settings object to be cleared.
      • copySetting

        public void copySetting​(Settings srcSettings,
                                Settings destSettings)
        Description copied from interface: SettingsDefinition
        Copies any setting value associated with this settings definition from the srcSettings settings to the destSettings.
        Specified by:
        copySetting in interface SettingsDefinition
        Parameters:
        srcSettings - the settings to be copied
        destSettings - the settings to be updated.
      • getChoice

        public int getChoice​(Settings settings)
        Description copied from interface: EnumSettingsDefinition
        Returns the current value for this settings
        Specified by:
        getChoice in interface EnumSettingsDefinition
        Parameters:
        settings - The settings to search
        Returns:
        the value for the settingsDefintions
      • setChoice

        public void setChoice​(Settings settings,
                              int value)
        Description copied from interface: EnumSettingsDefinition
        Sets the given value into the settings object using this definition as a key
        Specified by:
        setChoice in interface EnumSettingsDefinition
        Parameters:
        settings - the settings to store the value.
        value - the settings value to be stored.
      • getDisplayChoice

        public java.lang.String getDisplayChoice​(int value,
                                                 Settings settings)
        Description copied from interface: EnumSettingsDefinition
        Returns the String for the given enum value
        Specified by:
        getDisplayChoice in interface EnumSettingsDefinition
        Parameters:
        value - the value to get a display string for
        settings - the instance settings which may affect the results
        Returns:
        the display string for the given settings.
      • getDisplayChoices

        public java.lang.String[] getDisplayChoices​(Settings settings)
        Description copied from interface: EnumSettingsDefinition
        Gets the list of choices as strings based on the current settings
        Specified by:
        getDisplayChoices in interface EnumSettingsDefinition
        Parameters:
        settings - the instance settings
        Returns:
        an array of strings which represent valid choices based on the current settings.