Package ghidra.docking.settings
Class JavaEnumSettingsDefinition<T extends java.lang.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 java.lang.Enum<T>> extends java.lang.Object implements EnumSettingsDefinition
ASettingsDefinition
implementation that uses a real javaEnum
.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String[]
valueNames
-
Constructor Summary
Constructors Constructor Description JavaEnumSettingsDefinition(java.lang.String settingName, java.lang.String name, java.lang.String description, T defaultValue)
Creates a newJavaEnumSettingsDefinition
.
-
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 definitionvoid
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 settingsT
getDefaultEnum()
Returns the Enum instance that is the default Enum for thisSettingsDefinition
.java.lang.String
getDescription()
Returns a description of this settings definitionjava.lang.String
getDisplayChoice(int value, Settings settings)
Returns the String for the given enum valuejava.lang.String[]
getDisplayChoices(Settings settings)
Gets the list of choices as strings based on the current settingsT
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 thedefault 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 SettingsDefinitionint
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 aSettings
object.boolean
hasValue(Settings setting)
void
setChoice(Settings settings, int value)
Sets the given value into the settings object using this definition as a keyvoid
setEnumValue(Settings settings, T enumValue)
Sets the value of thisSettingsDefinition
using the ordinal of the specified enum.
-
-
-
Constructor Detail
-
JavaEnumSettingsDefinition
public JavaEnumSettingsDefinition(java.lang.String settingName, java.lang.String name, java.lang.String description, T defaultValue)
Creates a newJavaEnumSettingsDefinition
.- Parameters:
settingName
- String that specifies how this setting is storedname
- Descriptive name of this settingdescription
- Longer descriptiondefaultValue
- Enum instance that will be returned when thisSettingsDefinition
has not been specified yet.
-
-
Method Detail
-
getDefaultEnum
public T getDefaultEnum()
Returns the Enum instance that is the default Enum for thisSettingsDefinition
.- Returns:
- Enum
-
getEnumValue
public T getEnumValue(Settings settings)
Returns an enum instance that corresponds to the setting stored, or thedefault 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 thisSettingsDefinition
using the ordinal of the specified enum.- Parameters:
settings
- WhereSettingsDefinition
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 aSettings
object.- Returns:
- String name.
-
hasValue
public boolean hasValue(Settings setting)
- Specified by:
hasValue
in interfaceSettingsDefinition
-
getName
public java.lang.String getName()
Description copied from interface:SettingsDefinition
Returns the name of this SettingsDefinition- Specified by:
getName
in interfaceSettingsDefinition
-
getDescription
public java.lang.String getDescription()
Description copied from interface:SettingsDefinition
Returns a description of this settings definition- Specified by:
getDescription
in interfaceSettingsDefinition
-
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 interfaceSettingsDefinition
- 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 interfaceSettingsDefinition
- Parameters:
srcSettings
- the settings to be copieddestSettings
- 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 interfaceEnumSettingsDefinition
- 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 interfaceEnumSettingsDefinition
- 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 interfaceEnumSettingsDefinition
- Parameters:
value
- the value to get a display string forsettings
- 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 interfaceEnumSettingsDefinition
- Parameters:
settings
- the instance settings- Returns:
- an array of strings which represent valid choices based on the current settings.
-
-