java.lang.Object
is.codion.common.model.preferences.UserPreferences
A utility class for working with user preferences
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PropertyValue<String> Provides a way to override the default (OS dependent) directory used to store the user preferences file. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidDeletes the preferences file with the given name.static Preferencesstatic voidflush()Flushes the preferences to disk, including all file based preferences initialized viafile(String).static Stringstatic voidRemoves the preference associated with the given keystatic void
-
Field Details
-
PREFERENCES_LOCATION
Provides a way to override the default (OS dependent) directory used to store the user preferences file.- Value type: String
- Default value: null
- See Also:
-
-
Method Details
-
get
- Parameters:
key- the key identifying the preference- Returns:
- the user preference associated with the given key
-
get
- Parameters:
key- the key identifying the preferencedefaultValue- the default value if no preference is available- Returns:
- the user preference associated with the given key
- Throws:
NullPointerException- in casedefaultValueis null
-
set
- Parameters:
key- the key to use to identify the preferencevalue- the preference value to associate with the given key
-
remove
Removes the preference associated with the given key- Parameters:
key- the key to use to identify the preference to remove
-
flush
Flushes the preferences to disk, including all file based preferences initialized viafile(String).- Throws:
BackingStoreException- in case of a backing store failure
-
file
- Parameters:
filename- the preferences filename- Returns:
- a file based Preferences instance using the given filename
-
delete
Deletes the preferences file with the given name.- Parameters:
filename- the name of the preferences file to delete- Throws:
IOException- in case of an exceptionIllegalArgumentException- in case the given preferences file does not exist
-