Package org.apache.juneau.swap
Class MapSwap<T>
java.lang.Object
org.apache.juneau.swap.ObjectSwap<T,JsonMap>
org.apache.juneau.swap.MapSwap<T>
- Type Parameters:
T
- The normal form of the class.
Abstract subclass for object swaps that swap objects for object maps.
Example:
See Also:
-
Field Summary
Fields inherited from class org.apache.juneau.swap.ObjectSwap
NULL
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionswap
(BeanSession session, T o) If this transform is to be used to serialize non-serializable objects, it must implement this method.unswap
(BeanSession session, JsonMap f, ClassMeta<?> hint) If this transform is to be used to reconstitute objects that aren't true Java beans, it must implement this method.Methods inherited from class org.apache.juneau.swap.ObjectSwap
forMediaTypes, forMediaTypes, getNormalClass, getSwapClass, getSwapClassMeta, isNormalObject, isSwappedObject, match, swap, toString, unswap, withTemplate, withTemplate
-
Constructor Details
-
MapSwap
public MapSwap()
-
-
Method Details
-
swap
Description copied from class:ObjectSwap
If this transform is to be used to serialize non-serializable objects, it must implement this method.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. - A java bean with properties of anything on this list.
- An array of anything on this list.
- Overrides:
swap
in classObjectSwap<T,
JsonMap> - Parameters:
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.- Returns:
- The transformed object.
- Throws:
Exception
- If a problem occurred trying to convert the output.
-
-
unswap
Description copied from class:ObjectSwap
If this transform is to be used to reconstitute objects that aren't true Java beans, it must implement this method.- Overrides:
unswap
in classObjectSwap<T,
JsonMap> - Parameters:
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 typeGregorianCalendar
.
This may benull if the parser cannot make this determination.- Returns:
- The narrowed object.
- Throws:
Exception
- If this method is not implemented.
-