Class DefaultDeserializer

  • All Implemented Interfaces:
    SerDeserializer

    public class DefaultDeserializer
    extends java.lang.Object
    implements SerDeserializer
    Default deserializer that expects the input to match the current classpath beans.

    This uses the standard MetaBean, MetaProperty and BeanBuilder.

    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected DefaultDeserializer()
      Creates an instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Object build​(java.lang.Class<?> beanType, BeanBuilder<?> builder)
      Builds the resulting object.
      BeanBuilder<?> createBuilder​(java.lang.Class<?> beanType, MetaBean metaBean)
      Creates the stateful builder that captures state as the parse progresses.
      MetaBean findMetaBean​(java.lang.Class<?> beanType)
      Lookup the meta-bean for the specified type.
      MetaProperty<?> findMetaProperty​(java.lang.Class<?> beanType, MetaBean metaBean, java.lang.String propertyName)
      Lookup the meta-property for the specified property name.
      void setValue​(BeanBuilder<?> builder, MetaProperty<?> metaProp, java.lang.Object value)
      Sets the parsed value into the builder.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • DefaultDeserializer

        protected DefaultDeserializer()
        Creates an instance.
    • Method Detail

      • findMetaBean

        public MetaBean findMetaBean​(java.lang.Class<?> beanType)
        Description copied from interface: SerDeserializer
        Lookup the meta-bean for the specified type.

        If the type is not a bean, then null may be returned.

        Specified by:
        findMetaBean in interface SerDeserializer
        Parameters:
        beanType - the type being processed, not null
        Returns:
        the meta-bean, null if not a bean type
      • createBuilder

        public BeanBuilder<?> createBuilder​(java.lang.Class<?> beanType,
                                            MetaBean metaBean)
        Description copied from interface: SerDeserializer
        Creates the stateful builder that captures state as the parse progresses.

        This is normally a BeanBuilder however any type may be returned.

        Specified by:
        createBuilder in interface SerDeserializer
        Parameters:
        beanType - the type being processed, not null
        metaBean - the meta-bean, null if not a bean type
        Returns:
        the builder, null if not interested in the parse progress
      • findMetaProperty

        public MetaProperty<?> findMetaProperty​(java.lang.Class<?> beanType,
                                                MetaBean metaBean,
                                                java.lang.String propertyName)
        Description copied from interface: SerDeserializer
        Lookup the meta-property for the specified property name.

        Return null if a property has been deleted, which will cause the parser to discard the property.

        Return a non-null meta-property to parse the property. If the property was renamed, or had a type change, then the meta-property should match the property as originally stored.

        Specified by:
        findMetaProperty in interface SerDeserializer
        Parameters:
        beanType - the type being processed, not null
        metaBean - the meta-bean, null if not a bean type
        propertyName - the property name being parsed, not null
        Returns:
        the meta-property, null to ignore the property
      • setValue

        public void setValue​(BeanBuilder<?> builder,
                             MetaProperty<?> metaProp,
                             java.lang.Object value)
        Description copied from interface: SerDeserializer
        Sets the parsed value into the builder.
        Specified by:
        setValue in interface SerDeserializer
        Parameters:
        builder - the builder, null if not interested in the parse progress
        metaProp - the meta-property, not null
        value - the parsed value, may be null
      • build

        public java.lang.Object build​(java.lang.Class<?> beanType,
                                      BeanBuilder<?> builder)
        Description copied from interface: SerDeserializer
        Builds the resulting object.

        This method finishes the builder and returns the final object. The migrator could validate or manipulate data here once all data is parsed, for example to default a missing field.

        Specified by:
        build in interface SerDeserializer
        Parameters:
        beanType - the type being processed, not null
        builder - the builder, null if not interested in the parse progress
        Returns:
        the final built object, may be null
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object