Class FilePreferences

java.lang.Object
java.util.prefs.Preferences
java.util.prefs.AbstractPreferences
is.codion.common.model.preferences.FilePreferences

public final class FilePreferences extends AbstractPreferences

A file-based preferences implementation without length restrictions, on keys, values or node names.

Supports hierarchical preferences through nested JSON structure.

Clearing the preferences instance and flushing deletes the underlying file.

A value is returned as it was put, with one exception: a value that is an empty JSON object, {}, is not written to the file, nor is a node holding no values, so that neither is there once the file is read again. A JSON value is stored nested in the file and may come back with its members in another order.

A key and a child node can not share a name, both being stored in the same JSON object. Putting a value for a key naming a child node throws IllegalStateException, as does putting a value into a child node named after a key, while AbstractPreferences.get(String, String) and AbstractPreferences.remove(String) ignore child nodes.

Note that, unlike the AbstractPreferences contract, PreferenceChangeListeners are not notified of put(String, String) calls.

See Also: