@Documented @Target(value={TYPE,ANNOTATION_TYPE,FIELD,METHOD}) @Retention(value=RUNTIME) @Inherited public @interface Swap
Modifier and Type | Optional Element and Description |
---|---|
Class<?> |
impl
|
String[] |
mediaTypes
Identifies the media types that this swap is applicable for.
|
String |
on
Dynamically apply this annotation to the specified classes/methods/fields.
|
String |
template
Identifies a template string along with this swap.
|
Class<?> |
value
|
public abstract String[] mediaTypes
In the following example, the swap is only invoked by the JSON serializer:
public abstract String on
Used in conjunction with the BeanConfig.applySwap()
.
It is ignored when the annotation is applied directly to classes.
public abstract String template
Template strings are arbitrary strings associated with swaps that help provide additional context information for the swap class. They're called 'templates' because their primary purpose is for providing template names, such as Apache FreeMarker template names.
The following is an example of a templated swap class used to serialize POJOs to HTML using FreeMarker:
Copyright © 2016–2020 The Apache Software Foundation. All rights reserved.