Class MapAccessor<K,V> 
java.lang.Object
org.tquadrat.foundation.config.spi.prefs.PreferenceAccessor<Map<K,V>>
 
org.tquadrat.foundation.config.spi.prefs.MapAccessor<K,V> 
- Type Parameters:
- K- The key type of the- Map.
- V- The value type of the- Map.
@ClassVersion(sourceVersion="$Id: MapAccessor.java 1061 2023-09-25 16:32:43Z tquadrat $")
@API(status=STABLE,
     since="0.0.1")
public final class MapAccessor<K,V> 
extends PreferenceAccessor<Map<K,V>> 
The implementation of
  
PreferenceAccessor
  for instances of
  Map.- Note:
- 
- This class requires that there is an implementation of
      StringConverteravailable for both theMap's key and value types.
 
- This class requires that there is an implementation of
      
- Author:
- Thomas Thrien (thomas.thrien@tquadrat.org)
- Version:
- $Id: MapAccessor.java 1061 2023-09-25 16:32:43Z tquadrat $
- Since:
- 0.0.1
- UML Diagram
- 
    
         UML Diagram for "org.tquadrat.foundation.config.spi.prefs.MapAccessor" 
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprivate final StringConverter<K> The instance ofStringConverterthat is used to convert the key values.private final StringConverter<V> The instance ofStringConverterthat is used to convert the key values.
- 
Constructor SummaryConstructorsConstructorDescriptionMapAccessor(String propertyName, StringConverter<K> keyStringConverter, StringConverter<V> valueStringConverter, Getter<Map<K, V>> getter, Setter<Map<K, V>> setter) Creates a newMapAccessorinstance.
- 
Method SummaryModifier and TypeMethodDescriptionfromStringMap(Preferences node, Map<String, String> map) Converts the givenMap<String,String>to aMap<K,V>.final voidreadPreference(Preferences node) Reads the preference value from the given node and writes it to the property.toStringMap(Map<? extends K, ? extends V> map) Converts the givenMap<K,V>to aMap<String,String>.final 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.PreferenceAccessorgetPropertyName, getter, hasKey, setter
- 
Field Details- 
m_KeyStringConverterThe instance ofStringConverterthat is used to convert the key values.
- 
m_ValueStringConverterThe instance ofStringConverterthat is used to convert the key values.
 
- 
- 
Constructor Details- 
MapAccessorpublic MapAccessor(String propertyName, StringConverter<K> keyStringConverter, StringConverter<V> valueStringConverter, Getter<Map<K, V>> getter, Setter<Map<K, V>> setter) Creates a newMapAccessorinstance.- Parameters:
- propertyName- The name of the property.
- keyStringConverter- The implementation of- StringConverterfor the key type.
- valueStringConverter- The implementation of- StringConverterfor the value type.
- getter- The property getter.
- setter- The property setter.
 
 
- 
- 
Method Details- 
fromStringMapprivate final Map<K,V> fromStringMap(Preferences node, Map<String, String> map) throws InvalidPreferenceValueExceptionConverts the givenMap<String,String>to aMap<K,V>.- Parameters:
- node- The- Preferencesnode that provides the key and value.
- map- The input map; can be- null.
- Returns:
- The converted map; will be nullif the provided map wasnull.
- Throws:
- InvalidPreferenceValueException- The preferences value cannot be translated to the property type.
 
- 
readPreferencepublic final void readPreference(Preferences node) throws BackingStoreException, InvalidPreferenceValueException Reads the preference value from the given node and writes it to the property.- Specified by:
- readPreferencein class- PreferenceAccessor<Map<K,- V>> 
- 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.
 
- 
toStringMapConverts the givenMap<K,V>to aMap<String,String>.- Parameters:
- map- The input map.
- Returns:
- The converted map.
 
- 
writePreferenceWrites the preference value from the property and writes it to the given node.- Specified by:
- writePreferencein class- PreferenceAccessor<Map<K,- V>> 
- Parameters:
- node- The preference node.
- Throws:
- BackingStoreException- There are problems on writing the given node.
 
 
- 
