Class AbstractSourceData

  • All Implemented Interfaces:
    java.util.Map<java.lang.String,​java.lang.Object>, ISourceData
    Direct Known Subclasses:
    SourceData

    @StableMinor(version="17.0",
                 sinceVersion="4.0")
    public abstract class AbstractSourceData
    extends java.lang.Object
    implements ISourceData
    Abstract implementation of a ISourceData 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$ $Date$
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface java.util.Map

        java.util.Map.Entry<K extends java.lang.Object,​V extends java.lang.Object>
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected Source source
      The source this source data belongs to.
    • 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​(java.lang.String key, java.lang.Class<T> expectedClass, java.lang.Object value)
      Converts a value that is associated with a given key.
      <T> T get​(java.lang.Object key, java.lang.Class<T> expectedClass)
      Returns a data value, converted to the expected class.
      protected java.lang.Class<?> getValueClass​(java.lang.String key)
      Returns the class the value of the given key is to be kept as.
      void putAll​(java.util.Map<? extends java.lang.String,​? extends java.lang.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​(java.lang.String key,
                                     java.lang.Class<T> expectedClass,
                                     java.lang.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 java.lang.Class<?> getValueClass​(java.lang.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​(java.lang.Object key,
                         java.lang.Class<T> expectedClass)
        Description copied from interface: ISourceData
        Returns a data value, converted to the expected class.
        Specified by:
        get in interface ISourceData
        Type Parameters:
        T - the expected class.
        Parameters:
        key - the data entry key.
        expectedClass - the expected class.
        Returns:
        the converted data value.
      • putAll

        public void putAll​(java.util.Map<? extends java.lang.String,​? extends java.lang.Object> t)
        Specified by:
        putAll in interface java.util.Map<java.lang.String,​java.lang.Object>