Class SimpleBulkDataAccessor<T>
java.lang.Object
org.tquadrat.foundation.config.spi.prefs.PreferenceAccessor<T>
org.tquadrat.foundation.config.spi.prefs.BulkDataAccessorBase<T>
org.tquadrat.foundation.config.spi.prefs.SimpleBulkDataAccessor<T>
- Type Parameters:
T- The type of the property.
- Direct Known Subclasses:
TextAccessor
@ClassVersion(sourceVersion="$Id: SimpleBulkDataAccessor.java 914 2021-05-07 21:22:12Z tquadrat $")
@API(status=STABLE,
since="0.0.1")
public abstract class SimpleBulkDataAccessor<T>
extends BulkDataAccessorBase<T>
The abstract implementation of
BulkDataAccessorBase
for bulk data where an instance of
StringConverter
can be provided for the property data type.
The method
Preferences.put()
limits the length for a value String to
8192. If more data should be stored, the
method
Preferences.putByteArray()
can be used.
- Author:
- Thomas Thrien (thomas.thrien@tquadrat.org)
- Version:
- $Id: SimpleBulkDataAccessor.java 914 2021-05-07 21:22:12Z tquadrat $
- Since:
- 0.1.0
- UML Diagram
-
UML Diagram for "org.tquadrat.foundation.config.spi.prefs.SimpleBulkDataAccessor"
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final StringConverter<T> The implementation ofStringConverterthat is used to convert the preference values back and force. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSimpleBulkDataAccessor(String propertyName, Getter<T> getter, Setter<T> setter, StringConverter<T> stringConverter) Creates a newSimpleBulkDataAccessorinstance. -
Method Summary
Modifier and TypeMethodDescriptionprotected final TfromByteArray(Preferences node, byte[] source) Converts the givenbytearray to an instance of the property type.protected final byte[]toByteArray(Preferences node, T source) Converts the given instance of the property type into abytearray.Methods inherited from class org.tquadrat.foundation.config.spi.prefs.BulkDataAccessorBase
readPreference, writePreferenceMethods inherited from class org.tquadrat.foundation.config.spi.prefs.PreferenceAccessor
getPropertyName, getter, hasKey, setter
-
Field Details
-
m_StringConverter
The implementation ofStringConverterthat is used to convert the preference values back and force.
-
-
Constructor Details
-
SimpleBulkDataAccessor
protected SimpleBulkDataAccessor(String propertyName, Getter<T> getter, Setter<T> setter, StringConverter<T> stringConverter) Creates a newSimpleBulkDataAccessorinstance.- Parameters:
propertyName- The name of the property.getter- The property getter.setter- The property setter.stringConverter- The implementation ofStringConverterthat is used to convert the preference values back and force.
-
-
Method Details
-
fromByteArray
protected final T fromByteArray(Preferences node, byte[] source) throws InvalidPreferenceValueException Converts the givenbytearray to an instance of the property type.- Specified by:
fromByteArrayin classBulkDataAccessorBase<T>- Parameters:
node- The reference to thePreferencesnode that provides the value.source- The byte array; can benull.- Returns:
- The instance, or
nullif the source was alreadynull. - Throws:
InvalidPreferenceValueException- The preferences value cannot be translated to the property type.
-
toByteArray
protected final byte[] toByteArray(Preferences node, T source) throws InvalidPreferenceValueException Converts the given instance of the property type into abytearray.- Specified by:
toByteArrayin classBulkDataAccessorBase<T>- Parameters:
node- The reference to thePreferencesnode that is used to store the preferences value.source- The instance; can benull.- Returns:
- The
bytearray, ornullif the source was alreadynull. - Throws:
InvalidPreferenceValueException- The conversion failed to abytearray failed.
-
