Class AbstractBeanDescriptorProvider

    • Method Detail

      • provide

        public <T> BeanDescriptor<T> provide​(Class<T> type,
                                             Genson genson)
        Description copied from interface: BeanDescriptorProvider
        Provides a BeanDescriptor for "type" using current Genson instance.
        Specified by:
        provide in interface BeanDescriptorProvider
        Parameters:
        type - for which we need a BeanDescriptor.
        genson - current instance.
        Returns:
        A BeanDescriptor instance able to serialize/deserialize objects of type T.
      • provide

        public <T> BeanDescriptor<T> provide​(Class<T> ofClass,
                                             Type ofType,
                                             Genson genson)
        Description copied from interface: BeanDescriptorProvider
        Provides a BeanDescriptor that can serialize/deserialize "ofClass" type, based on "type" argument. The arguments "ofClass" and "type" will be the same in most cases, but for example in BeanViews ofClass will correspond to the parameterized type and "type" to the BeanView implementation.
        Specified by:
        provide in interface BeanDescriptorProvider
        Parameters:
        ofClass - is the Class for which we need a BeanDescriptor that will be able to serialize/deserialize objects of that type;
        ofType - to use to build this descriptor (use its declared methods, fields, etc).
        genson - is the current Genson instance.
        Returns:
        A BeanDescriptor instance able to serialize/deserialize objects of type ofClass.
      • create

        protected <T> BeanDescriptor<T> create​(Class<T> forClass,
                                               Type ofType,
                                               BeanCreator creator,
                                               List<PropertyAccessor> accessors,
                                               Map<String,​PropertyMutator> mutators,
                                               Genson genson)
        Creates an instance of BeanDescriptor based on the passed arguments. Subclasses can override this method to create their own BeanDescriptors.
        Parameters:
        forClass -
        ofType -
        creator -
        accessors -
        mutators -
        Returns:
        a instance
      • provideBeanCreators

        protected abstract List<BeanCreator> provideBeanCreators​(Type ofType,
                                                                 Genson genson)
        Provides a list of BeanCreator for type ofType.
        Parameters:
        ofType -
        genson -
        Returns:
        a list of resolved bean creators
      • checkAndMerge

        protected abstract BeanCreator checkAndMerge​(Type ofType,
                                                     List<BeanCreator> creators)
        Implementations of this method can do some additional checks on the creators validity or do any other operations related to creators. This method must merge all creators into a single one.
        Parameters:
        creators -
        Returns:
        the creator that will be used by the BeanDescriptor
      • checkAndMergeMutators

        protected abstract PropertyMutator checkAndMergeMutators​(String name,
                                                                 LinkedList<PropertyMutator> mutators)
        Implementations are supposed to merge the PropertyMutators from mutators list into a single PropertyMutator.
        Parameters:
        name -
        mutators -
        Returns:
        a single PropertyMutator or null.
      • mergeMutatorsWithCreatorProperties

        protected abstract void mergeMutatorsWithCreatorProperties​(Type ofType,
                                                                   Map<String,​PropertyMutator> mutators,
                                                                   BeanCreator creator)
        Implementations may do additional merge operations based on the resolved creator parameters and the resolved mutators.
        Parameters:
        ofType -
        mutators -
        creator -
      • mergeAccessorsWithCreatorProperties

        protected abstract void mergeAccessorsWithCreatorProperties​(Type ofType,
                                                                    List<PropertyAccessor> accessors,
                                                                    BeanCreator creator)
        Implementations may do additional merge operations based on the resolved creator parameters and the resolved accessors.
        Parameters:
        ofType -
        accessors -
        creator -
      • checkAndMergeAccessors

        protected abstract PropertyAccessor checkAndMergeAccessors​(String name,
                                                                   LinkedList<PropertyAccessor> accessors)
        Implementations are supposed to merge the PropertyAccessors from accessors list into a single PropertyAccessor.
        Parameters:
        name -
        accessors -
        Returns:
        a single property accessor for this name