Package lumis.doui.source
Class AbstractSourceData
- java.lang.Object
-
- lumis.doui.source.AbstractSourceData
-
- All Implemented Interfaces:
Map<String,Object>
,ISourceData
- Direct Known Subclasses:
SourceData
@StableMinor(version="14.0", sinceVersion="4.0") public abstract class AbstractSourceData extends Object implements ISourceData
Abstract implementation of aISourceData
that implements the default convertion behaviour. This convertion behaviour assumes the key is equals to the field id in the source.This implementation does no conversion during the put method, it does conversion only during the get method. But it offers the
convertValue(String, Class, Object)
method to be used by it subclasses in the put implementation.- Since:
- 4.0.4
- Version:
- $Revision: 24476 $ $Date: 2021-04-28 11:28:23 -0300 (Wed, 28 Apr 2021) $
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractSourceData()
Creates a source data without source associated.protected
AbstractSourceData(Source source)
Creates a source data associated with the given source.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected <T> T
convertValue(String key, Class<T> expectedClass, Object value)
Converts a value that is associated with a given key.<T> T
get(Object key, Class<T> expectedClass)
Returns a data value, converted to the expected class.protected Class<?>
getValueClass(String key)
Returns the class the value of the given key is to be kept as.void
putAll(Map<? extends String,? extends Object> t)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Map
clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keySet, merge, put, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
-
-
-
-
Field Detail
-
source
protected final Source source
The source this source data belongs to.- Since:
- 4.0.4
-
-
Constructor Detail
-
AbstractSourceData
protected AbstractSourceData(Source source)
Creates a source data associated with the given source.- Parameters:
source
- the source that this data will belong to.- Since:
- 4.0.4
-
AbstractSourceData
protected AbstractSourceData()
Creates a source data without source associated.- Parameters:
source
- the source that this data will belong to.- Since:
- 4.0.4
-
-
Method Detail
-
convertValue
protected <T> T convertValue(String key, Class<T> expectedClass, Object value)
Converts a value that is associated with a given key.- Type Parameters:
T
- the expected return class.- Parameters:
key
- the key.expectedClass
- the expected return class.value
- the value to be converted.- Returns:
- the value converted.
- Since:
- 4.0.4
-
getValueClass
protected Class<?> getValueClass(String key)
Returns the class the value of the given key is to be kept as.- Parameters:
key
- the key.- Returns:
- the class.
- Since:
- 4.0.4
-
get
public <T> T get(Object key, Class<T> expectedClass)
Description copied from interface:ISourceData
Returns a data value, converted to the expected class.- Specified by:
get
in interfaceISourceData
- Type Parameters:
T
- the expected class.- Parameters:
key
- the data entry key.expectedClass
- the expected class.- Returns:
- the converted data value.
-
-