Class AbstractBeanDescriptorProvider
- java.lang.Object
-
- com.oracle.coherence.io.json.genson.reflect.AbstractBeanDescriptorProvider
-
- All Implemented Interfaces:
BeanDescriptorProvider
- Direct Known Subclasses:
BaseBeanDescriptorProvider
public abstract class AbstractBeanDescriptorProvider extends Object implements BeanDescriptorProvider
Abstract implementation ofBeanDescriptorProviderapplying the template pattern. If you wonder how to implement the different abstract methods defined in this class have a look at the BaseBeanDescriptorProvider.- Author:
- Eugen Cepoi
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAbstractBeanDescriptorProvider.ContextualConverterFactorystatic classAbstractBeanDescriptorProvider.ContextualFactoryDecorator-
Nested classes/interfaces inherited from interface com.oracle.coherence.io.json.genson.reflect.BeanDescriptorProvider
BeanDescriptorProvider.CompositeBeanDescriptorProvider
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractBeanDescriptorProvider(AbstractBeanDescriptorProvider.ContextualConverterFactory contextualConverterFactory)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract BeanCreatorcheckAndMerge(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.protected abstract PropertyAccessorcheckAndMergeAccessors(String name, LinkedList<PropertyAccessor> accessors)Implementations are supposed to merge thePropertyAccessors from accessors list into a single PropertyAccessor.protected abstract PropertyMutatorcheckAndMergeMutators(String name, LinkedList<PropertyMutator> mutators)Implementations are supposed to merge thePropertyMutators from mutators list into a single PropertyMutator.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.protected abstract voidmergeAccessorsWithCreatorProperties(Type ofType, List<PropertyAccessor> accessors, BeanCreator creator)Implementations may do additional merge operations based on the resolved creator parameters and the resolved accessors.protected abstract voidmergeMutatorsWithCreatorProperties(Type ofType, Map<String,PropertyMutator> mutators, BeanCreator creator)Implementations may do additional merge operations based on the resolved creator parameters and the resolved mutators.<T> BeanDescriptor<T>provide(Class<T> type, Genson genson)Provides a BeanDescriptor for "type" using current Genson instance.<T> BeanDescriptor<T>provide(Class<T> ofClass, Type ofType, Genson genson)Provides a BeanDescriptor that can serialize/deserialize "ofClass" type, based on "type" argument.protected abstract List<BeanCreator>provideBeanCreators(Type ofType, Genson genson)Provides a list ofBeanCreatorfor type ofType.protected abstract voidprovideBeanPropertyAccessors(Type ofType, Map<String,LinkedList<PropertyAccessor>> accessorsMap, Genson genson)Adds resolvedPropertyAccessorto accessorsMap.protected abstract voidprovideBeanPropertyMutators(Type ofType, Map<String,LinkedList<PropertyMutator>> mutatorsMap, Genson genson)Adds resolvedPropertyMutatorto mutatorsMap.
-
-
-
Constructor Detail
-
AbstractBeanDescriptorProvider
protected AbstractBeanDescriptorProvider(AbstractBeanDescriptorProvider.ContextualConverterFactory contextualConverterFactory)
-
-
Method Detail
-
provide
public <T> BeanDescriptor<T> provide(Class<T> type, Genson genson)
Description copied from interface:BeanDescriptorProviderProvides a BeanDescriptor for "type" using current Genson instance.- Specified by:
providein interfaceBeanDescriptorProvider- 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:BeanDescriptorProviderProvides 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:
providein interfaceBeanDescriptorProvider- 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 ofBeanCreatorfor type ofType.- Parameters:
ofType-genson-- Returns:
- a list of resolved bean creators
-
provideBeanPropertyMutators
protected abstract void provideBeanPropertyMutators(Type ofType, Map<String,LinkedList<PropertyMutator>> mutatorsMap, Genson genson)
Adds resolvedPropertyMutatorto mutatorsMap.- Parameters:
ofType-mutatorsMap-genson-
-
provideBeanPropertyAccessors
protected abstract void provideBeanPropertyAccessors(Type ofType, Map<String,LinkedList<PropertyAccessor>> accessorsMap, Genson genson)
Adds resolvedPropertyAccessorto accessorsMap.- Parameters:
ofType-accessorsMap-genson-
-
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 thePropertyMutators 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 thePropertyAccessors from accessors list into a single PropertyAccessor.- Parameters:
name-accessors-- Returns:
- a single property accessor for this name
-
-