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
ASettingsDefinitionimplementation 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 voidclear(Settings settings)Removes any values in the given settings object assocated with this settings definitionvoidcopySetting(Settings srcSettings, Settings destSettings)Copies any setting value associated with this settings definition from the srcSettings settings to the destSettings.intgetChoice(Settings settings)Returns the current value for this settingsTgetDefaultEnum()Returns the Enum instance that is the default Enum for thisSettingsDefinition.java.lang.StringgetDescription()Returns a description of this settings definitionjava.lang.StringgetDisplayChoice(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 settingsTgetEnumByOrdinal(int ordinal)Returns the Enum instance that corresponds to the specified ordinal value.TgetEnumValue(Settings settings)Returns an enum instance that corresponds to the setting stored, or thedefault enumif the setting has not been assigned yet.TgetEnumValue(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.StringgetName()Returns the name of this SettingsDefinitionintgetOrdinalByString(java.lang.String stringValue)returns the Enum's ordinal using the Enum's string representation.java.lang.StringgetSettingName()The name of this setting as it is stored in aSettingsobject.booleanhasValue(Settings setting)voidsetChoice(Settings settings, int value)Sets the given value into the settings object using this definition as a keyvoidsetEnumValue(Settings settings, T enumValue)Sets the value of thisSettingsDefinitionusing 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 thisSettingsDefinitionhas 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 enumif the setting has not been assigned yet.- Parameters:
settings-Settingsobject 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-Settingsobject 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 thisSettingsDefinitionusing the ordinal of the specified enum.- Parameters:
settings- WhereSettingsDefinitionvalues 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 aSettingsobject.- Returns:
- String name.
-
hasValue
public boolean hasValue(Settings setting)
- Specified by:
hasValuein interfaceSettingsDefinition
-
getName
public java.lang.String getName()
Description copied from interface:SettingsDefinitionReturns the name of this SettingsDefinition- Specified by:
getNamein interfaceSettingsDefinition
-
getDescription
public java.lang.String getDescription()
Description copied from interface:SettingsDefinitionReturns a description of this settings definition- Specified by:
getDescriptionin interfaceSettingsDefinition
-
clear
public void clear(Settings settings)
Description copied from interface:SettingsDefinitionRemoves any values in the given settings object assocated with this settings definition- Specified by:
clearin interfaceSettingsDefinition- Parameters:
settings- the settings object to be cleared.
-
copySetting
public void copySetting(Settings srcSettings, Settings destSettings)
Description copied from interface:SettingsDefinitionCopies any setting value associated with this settings definition from the srcSettings settings to the destSettings.- Specified by:
copySettingin interfaceSettingsDefinition- Parameters:
srcSettings- the settings to be copieddestSettings- the settings to be updated.
-
getChoice
public int getChoice(Settings settings)
Description copied from interface:EnumSettingsDefinitionReturns the current value for this settings- Specified by:
getChoicein 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:EnumSettingsDefinitionSets the given value into the settings object using this definition as a key- Specified by:
setChoicein 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:EnumSettingsDefinitionReturns the String for the given enum value- Specified by:
getDisplayChoicein 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:EnumSettingsDefinitionGets the list of choices as strings based on the current settings- Specified by:
getDisplayChoicesin interfaceEnumSettingsDefinition- Parameters:
settings- the instance settings- Returns:
- an array of strings which represent valid choices based on the current settings.
-
-