T
- The class type that this transform applies to.F
- The transformed class type.public class SurrogateSwap<T,F> extends PojoSwap<T,F>
Modifier | Constructor and Description |
---|---|
protected |
SurrogateSwap(Class<T> forClass,
Constructor<F> constructor,
Method unswapMethod)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
static List<SurrogateSwap<?,?>> |
findPojoSwaps(Class<?> c)
Given the specified surrogate class, return the list of POJO swaps.
|
F |
swap(BeanSession session,
T o)
If this transform is to be used to serialize non-serializable POJOs, it must implement this method.
|
T |
unswap(BeanSession session,
F f,
ClassMeta<?> hint)
If this transform is to be used to reconstitute POJOs that aren't true Java beans, it must implement this method.
|
forMediaTypes, forMediaTypes, getNormalClass, getSwapClass, getSwapClassMeta, isNormalObject, isSwappedObject, match, swap, toString, unswap, withTemplate, withTemplate
protected SurrogateSwap(Class<T> forClass, Constructor<F> constructor, Method unswapMethod)
forClass
- The normal class.constructor
- The constructor on the surrogate class that takes the normal class as a parameter.unswapMethod
- The static method that converts surrogate objects into normal objects.public static List<SurrogateSwap<?,?>> findPojoSwaps(Class<?> c)
A transform is returned for each public 1-arg constructor found. Returns an empty list if no public 1-arg constructors are found.
c
- The surrogate class.public F swap(BeanSession session, T o) throws SerializeException
PojoSwap
The object must be converted into one of the following serializable types:
String
Number
Boolean
Collection
containing anything on this list.
Map
containing anything on this list.
swap
in class PojoSwap<T,F>
session
- The bean session to use to get the class meta.
This is always going to be the same bean context that created this swap.o
- The object to be transformed.SerializeException
public T unswap(BeanSession session, F f, ClassMeta<?> hint) throws ParseException
PojoSwap
unswap
in class PojoSwap<T,F>
session
- The bean session to use to get the class meta.
This is always going to be the same bean context that created this swap.f
- The transformed object.hint
- If possible, the parser will try to tell you the object type being created.
For example, on a serialized date, this may tell you that the object being created must be of type
GregorianCalendar
.
ParseException
Copyright © 2016–2019 The Apache Software Foundation. All rights reserved.