Class AbstractSourceData

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

    @StableMinor(version="14.2",
                 sinceVersion="4.0")
    public abstract class AbstractSourceData
    extends 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: 24985 $ $Date: 2022-05-02 23:04:30 -0300 (Mon, 02 May 2022) $
    • 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 interface ISourceData
        Type Parameters:
        T - the expected class.
        Parameters:
        key - the data entry key.
        expectedClass - the expected class.
        Returns:
        the converted data value.