Class JavaEnumSettingsDefinition<T extends Enum<T>>

java.lang.Object
ghidra.docking.settings.JavaEnumSettingsDefinition<T>
Type Parameters:
T - java Enum that defines the possible values to store.
All Implemented Interfaces:
EnumSettingsDefinition, SettingsDefinition
Direct Known Subclasses:
RenderUnicodeSettingsDefinition, TranslationSettingsDefinition

public class JavaEnumSettingsDefinition<T extends Enum<T>> extends Object implements EnumSettingsDefinition
A SettingsDefinition implementation that uses a real java Enum.
  • Field Details

    • valueNames

      protected final String[] valueNames
  • Constructor Details

    • JavaEnumSettingsDefinition

      public JavaEnumSettingsDefinition(String settingName, String name, 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 Details

    • 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(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
    • hasValue

      public boolean hasValue(Settings setting)
      Description copied from interface: SettingsDefinition
      Determine if a setting value has been stored
      Specified by:
      hasValue in interface SettingsDefinition
      Parameters:
      setting - stored settings
      Returns:
      true if a value has been stored, else false
    • getName

      public final String getName()
      Description copied from interface: SettingsDefinition
      Returns the display name of this SettingsDefinition
      Specified by:
      getName in interface SettingsDefinition
      Returns:
      display name for setting
    • getStorageKey

      public final String getStorageKey()
      Description copied from interface: SettingsDefinition
      Get the Settings key which is used when storing a key/value entry.
      Specified by:
      getStorageKey in interface SettingsDefinition
      Returns:
      settings storage key
    • getDescription

      public final String getDescription()
      Description copied from interface: SettingsDefinition
      Returns a description of this settings definition
      Specified by:
      getDescription in interface SettingsDefinition
      Returns:
      setting description
    • 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
    • getValueString

      public String getValueString(Settings settings)
      Description copied from interface: SettingsDefinition
      Get the setting value as a string which corresponds to this definition. A default value string will be returned if a setting has not been stored.
      Specified by:
      getValueString in interface SettingsDefinition
      Parameters:
      settings - settings
      Returns:
      value string or null if not set and default has not specified by this definition
    • 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 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 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.