Package org.apache.juneau.swaps
Class BeanStringSwap<T>
java.lang.Object
org.apache.juneau.swap.ObjectSwap<T,String>
org.apache.juneau.swap.StringSwap<T>
org.apache.juneau.swaps.BeanStringSwap<T>
- Type Parameters:
T
- The class type of the bean.
Transforms beans into
Strings
by simply calling the Object.toString()
method.
Allows you to specify classes that should just be converted to Strings
instead of potentially
being turned into Maps by the BeanContext
(or worse, throwing
BeanRuntimeExceptions
).
This is usually a one-way transform. Beans serialized as strings cannot be reconstituted using a parser unless it is a parsable POJO.
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) Converts the specified bean to aString
.Methods inherited from class org.apache.juneau.swap.StringSwap
unswap
Methods inherited from class org.apache.juneau.swap.ObjectSwap
forMediaTypes, forMediaTypes, getNormalClass, getSwapClass, getSwapClassMeta, isNormalObject, isSwappedObject, match, swap, toString, unswap, withTemplate, withTemplate
-
Constructor Details
-
BeanStringSwap
public BeanStringSwap()
-
-
Method Details
-
swap
Converts the specified bean to aString
.- Overrides:
swap
in classStringSwap<T>
- 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.
-