Class PreferenceAccessorBase<T>
java.lang.Object
org.tquadrat.foundation.config.spi.prefs.PreferenceAccessor<T>
org.tquadrat.foundation.config.spi.prefs.PreferenceAccessorBase<T>
- Type Parameters:
T- The type of the property.
- Direct Known Subclasses:
SimplePreferenceAccessor
@ClassVersion(sourceVersion="$Id: PreferenceAccessorBase.java 1061 2023-09-25 16:32:43Z tquadrat $")
@API(status=STABLE,
since="0.0.1")
public abstract class PreferenceAccessorBase<T>
extends PreferenceAccessor<T>
The abstract base class for custom implementations of
PreferenceAccessor.- Author:
- Thomas Thrien (thomas.thrien@tquadrat.org)
- Version:
- $Id: PreferenceAccessorBase.java 1061 2023-09-25 16:32:43Z tquadrat $
- Since:
- 0.0.1
- UML Diagram
-
UML Diagram for "org.tquadrat.foundation.config.spi.prefs.PreferenceAccessorBase"
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract TfromString(Preferences node, String s) Converts the given String to an instance of the property type.voidreadPreference(Preferences node) Reads the preference value from the given node and writes it to the property.protected abstract StringConverts the given instance of the property type to a String.voidwritePreference(Preferences node) Writes the preference value from the property and writes it to the given node.Methods inherited from class org.tquadrat.foundation.config.spi.prefs.PreferenceAccessor
getPropertyName, getter, hasKey, setter
-
Constructor Details
-
PreferenceAccessorBase
Creates a newPreferenceAccessorBaseinstance.- Parameters:
propertyName- The name of the property.getter- The property getter.setter- The property setter.
-
-
Method Details
-
fromString
Converts the given String to an instance of the property type.
This implementation uses
StringConverter.fromString(CharSequence)for the conversion.- Parameters:
node- The "preferences" node that provides the value.s- The String value; can benull.- Returns:
- The propertyType instance; will be
nullif the provided String isnullor cannot be converted to the property type. - Throws:
InvalidPreferenceValueException- The preferences value cannot be translated to the property type.
-
readPreference
public void readPreference(Preferences node) throws BackingStoreException, InvalidPreferenceValueException Reads the preference value from the given node and writes it to the property.- Specified by:
readPreferencein classPreferenceAccessor<T>- Parameters:
node- The preference node.- Throws:
BackingStoreException- There are problems on reading the given node.InvalidPreferenceValueException- The preferences value cannot be translated to the property type.
-
toString
Converts the given instance of the property type to a String.
This implementation uses
StringConverter.toString(Object)for the conversion.- Parameters:
t- The property value; can benull.- Returns:
- The String implementation; will be
nullif the provided value isnullor cannot be converted to a String.
-
writePreference
Writes the preference value from the property and writes it to the given node.- Specified by:
writePreferencein classPreferenceAccessor<T>- Parameters:
node- The preference node.- Throws:
BackingStoreException- There are problems on writing the given node.
-
