Package org.apache.juneau.swap
Class FunctionalSwap<T,S> 
java.lang.Object
org.apache.juneau.swap.ObjectSwap<T,S>
 
org.apache.juneau.swap.FunctionalSwap<T,S> 
- Type Parameters:
- T- The normal form of the class.
- S- The swapped form of the class.
A subclass of 
ObjectSwap that allows swap and unswap methods to be defined as functions.
 
   
See Also:
- 
Field SummaryFields inherited from class org.apache.juneau.swap.ObjectSwapNULL
- 
Constructor SummaryConstructorsConstructorDescriptionFunctionalSwap(Class<T> normalClass, Class<S> swappedClass, ThrowingFunction<T, S> swapFunction) Constructor.FunctionalSwap(Class<T> normalClass, Class<S> swappedClass, ThrowingFunction<T, S> swapFunction, ThrowingFunction<S, T> unswapFunction) Constructor.
- 
Method SummaryModifier and TypeMethodDescriptionswap(BeanSession session, T o, String template) Same asObjectSwap.swap(BeanSession, Object), but can be used if your swap has a template associated with it.unswap(BeanSession session, S f, ClassMeta<?> hint, String template) Same asObjectSwap.unswap(BeanSession, Object, ClassMeta), but can be used if your swap has a template associated with it.Methods inherited from class org.apache.juneau.swap.ObjectSwapforMediaTypes, forMediaTypes, getNormalClass, getSwapClass, getSwapClassMeta, isNormalObject, isSwappedObject, match, swap, toString, unswap, withTemplate, withTemplate
- 
Constructor Details- 
FunctionalSwappublic FunctionalSwap(Class<T> normalClass, Class<S> swappedClass, ThrowingFunction<T, S> swapFunction) Constructor.- Parameters:
- normalClass- The normal class.
- swappedClass- The swapped class.
- swapFunction- The function for converting from normal to swapped.
 
- 
FunctionalSwappublic FunctionalSwap(Class<T> normalClass, Class<S> swappedClass, ThrowingFunction<T, S> swapFunction, ThrowingFunction<S, T> unswapFunction) Constructor.- Parameters:
- normalClass- The normal class.
- swappedClass- The swapped class.
- swapFunction- The function for converting from normal to swapped.
- unswapFunction- The function for converting swapped to normal.
 
 
- 
- 
Method Details- 
swapDescription copied from class:ObjectSwapSame asObjectSwap.swap(BeanSession, Object), but can be used if your swap has a template associated with it.- Overrides:
- swapin class- ObjectSwap<T,- S> 
- 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.
- template- The template string associated with this swap.
- Returns:
- The transformed object.
- Throws:
- Exception- If a problem occurred trying to convert the output.
 
- 
unswapDescription copied from class:ObjectSwapSame asObjectSwap.unswap(BeanSession, Object, ClassMeta), but can be used if your swap has a template associated with it.- Overrides:
- unswapin class- ObjectSwap<T,- S> 
- 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 type- GregorianCalendar.
 This may be- null if the parser cannot make this determination.
- template- The template string associated with this swap.
- Returns:
- The transformed object.
- Throws:
- Exception- If a problem occurred trying to convert the output.
 
 
-