|
6 | 6 | import java.lang.annotation.Target;
|
7 | 7 |
|
8 | 8 | /**
|
9 |
| - * Marker annotation similar to |
10 |
| - * {@link javax.xml.bind.annotation.XmlValue} |
11 |
| - * that indicates that results of the annotated "getter" method |
12 |
| - * (which means signature must be that of getters; non-void return |
13 |
| - * type, no args) is to be used as the single value to serialize |
14 |
| - * for the instance. Usually value will be of a simple scalar type |
| 9 | + * Marker annotation |
| 10 | + * that indicates that the value of annotated accessor (either field |
| 11 | + * or "getter" method [a method with non-void return type, no args]) |
| 12 | + * is to be used as the single value to serialize for the instance, |
| 13 | + * instead of the usual method of collecting properties of value. |
| 14 | + * Usually value will be of a simple scalar type |
15 | 15 | * (String or Number), but it can be any serializable type (Collection,
|
16 | 16 | * Map or Bean).
|
17 | 17 | *<p>
|
18 |
| - * At most one method of a <code>Class</code> can be annotated with this annotation; |
| 18 | + * At most one accessor of a <code>Class</code> can be annotated with this annotation; |
19 | 19 | * if more than one is found, an exception may be thrown.
|
20 |
| - * Also, if method signature is not compatible with Getters, an exception |
21 |
| - * may be thrown (whether exception is thrown or not is an implementation detail (due |
22 |
| - * to filtering during introspection, some annotations may be skipped) |
23 |
| - * and applications should not rely on specific behavior). |
| 20 | + * Also, if method signature of annotated method is not compatible with Getters, |
| 21 | + * an exception may be thrown (whether exception is thrown or not is an |
| 22 | + * implementation detail (due to filtering during introspection, some annotations |
| 23 | + * may be skipped) and applications should not rely on specific behavior). |
24 | 24 | *<p>
|
25 | 25 | * A typical usage is that of annotating <code>toString()</code>
|
26 | 26 | * method so that returned String value is used as the JSON serialization;
|
|
39 | 39 | *
|
40 | 40 | * @see JsonCreator
|
41 | 41 | */
|
42 |
| -@Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD}) |
| 42 | +@Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD, |
| 43 | + ElementType.FIELD // since 2.9 |
| 44 | +}) |
43 | 45 | @Retention(RetentionPolicy.RUNTIME)
|
44 | 46 | @JacksonAnnotation
|
45 | 47 | public @interface JsonValue
|
|
0 commit comments