public class PathPreference extends Preference<java.nio.file.Path>
Path preference.| Modifier and Type | Field and Description |
|---|---|
static java.util.function.Predicate<java.nio.file.Path> |
IS_DIRECTORY
Files.isDirectory(Path, java.nio.file.LinkOption...) validator. |
static java.util.function.Predicate<java.nio.file.Path> |
IS_REGULAR_FILE
Files.isRegularFile(Path, java.nio.file.LinkOption...) validator. |
| Constructor and Description |
|---|
PathPreference(java.util.prefs.Preferences preferences,
java.lang.String key)
Construct
PathPreference. |
PathPreference(java.util.prefs.Preferences preferences,
java.lang.String key,
java.util.function.Predicate<java.nio.file.Path> validator)
Construct
PathPreference. |
| Modifier and Type | Method and Description |
|---|---|
protected java.lang.String |
fromValue(java.nio.file.Path value)
Convert the preference value to it's string representation.
|
java.io.File |
getValueAsFile()
Get the preference value as a
File object. |
java.io.File |
getValueAsFile(java.io.File defaultValue)
Get the preference value as a
File object. |
void |
putValueFromFile(java.io.File value)
Set the preference value from a
File object. |
protected java.nio.file.Path |
toValue(java.lang.String valueString)
Convert the preference's string representation to it's value.
|
get, get, key, preferences, put, remove, toStringpublic static final java.util.function.Predicate<java.nio.file.Path> IS_REGULAR_FILE
Files.isRegularFile(Path, java.nio.file.LinkOption...) validator.public static final java.util.function.Predicate<java.nio.file.Path> IS_DIRECTORY
Files.isDirectory(Path, java.nio.file.LinkOption...) validator.public PathPreference(java.util.prefs.Preferences preferences,
java.lang.String key)
PathPreference.preferences - The Preferences object storing this preference.key - The preference key.public PathPreference(java.util.prefs.Preferences preferences,
java.lang.String key,
java.util.function.Predicate<java.nio.file.Path> validator)
PathPreference.preferences - The Preferences object storing this preference.key - The preference key.validator - Predicate to use for preference value validation.@Nullable public java.io.File getValueAsFile()
File object.null if the preference is undefined.@Nullable public java.io.File getValueAsFile(@Nullable java.io.File defaultValue)
File object.defaultValue - The default preference value to return in case the preference is undefined.public void putValueFromFile(@Nullable java.io.File value)
File object.value - The value to set. If null the preference is removed.@Nullable protected java.nio.file.Path toValue(java.lang.String valueString)
PreferencetoValue in class Preference<java.nio.file.Path>valueString - The string to convert.protected java.lang.String fromValue(java.nio.file.Path value)
PreferencefromValue in class Preference<java.nio.file.Path>value - The value to convert.