Class BeanDescriptor<T>
- java.lang.Object
-
- com.oracle.coherence.io.json.genson.reflect.BeanDescriptor<T>
-
- Type Parameters:
T- type that this BeanDescriptor can serialize and deserialize.
- All Implemented Interfaces:
Converter<T>,Deserializer<T>,Serializer<T>
public class BeanDescriptor<T> extends Object implements Converter<T>
BeanDescriptors are used to serialize/deserialize objects based on their fields, methods and constructors. By default it is supposed to work on JavaBeans, however it can be configured and extended to support different kind of objects. In most cases BeanDescriptors should not be used directly as it is used internally to support objects not handled by the default Converters. The most frequent case when you will use directly a BeanDescriptor is when you want to deserialize into an existing instance. Here is an example :Genson genson = new Genson(); BeanDescriptorProvider provider = genson.getBeanDescriptorProvider(); BeanDescriptor<MyClass> descriptor = provider.provide(MyClass.class, genson); MyClass existingInstance = descriptor.deserialize(existingInstance, new JsonReader("{}"), new Context(genson));- Author:
- Eugen Cepoi
- See Also:
BeanDescriptorProvider
-
-
Constructor Summary
Constructors Constructor Description BeanDescriptor(Class<T> forClass, Class<?> fromDeclaringClass, List<PropertyAccessor> readableBps, Map<String,PropertyMutator> writableBps, BeanCreator creator, boolean failOnMissingProperty)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected T_deserWithCtrArgs(ObjectReader reader, Context ctx)Tdeserialize(ObjectReader reader, Context ctx)voiddeserialize(T into, ObjectReader reader, Context ctx)Class<T>getOfClass()booleanisReadable()booleanisWritable()voidserialize(T obj, ObjectWriter writer, Context ctx)
-
-
-
Constructor Detail
-
BeanDescriptor
public BeanDescriptor(Class<T> forClass, Class<?> fromDeclaringClass, List<PropertyAccessor> readableBps, Map<String,PropertyMutator> writableBps, BeanCreator creator, boolean failOnMissingProperty)
-
-
Method Detail
-
isReadable
public boolean isReadable()
-
isWritable
public boolean isWritable()
-
serialize
public void serialize(T obj, ObjectWriter writer, Context ctx)
- Specified by:
serializein interfaceConverter<T>- Specified by:
serializein interfaceSerializer<T>- Parameters:
obj- we want to serialize. The object is of type T or a subclass (if this serializer has been registered for subclasses).writer- to use to write data to the output stream.ctx- the current context.
-
deserialize
public T deserialize(ObjectReader reader, Context ctx)
- Specified by:
deserializein interfaceConverter<T>- Specified by:
deserializein interfaceDeserializer<T>- Parameters:
reader- used to read data from.ctx- the current context.- Returns:
- an instance of T or a subclass of T.
-
deserialize
public void deserialize(T into, ObjectReader reader, Context ctx)
-
_deserWithCtrArgs
protected T _deserWithCtrArgs(ObjectReader reader, Context ctx)
-
-