xref: /aosp_15_r20/external/jackson-annotations/src/main/java/com/fasterxml/jackson/annotation/JsonAnySetter.java (revision 2bf6642460ffb10303bd46207a4555f36d9e5945)
1 package com.fasterxml.jackson.annotation;
2 
3 import java.lang.annotation.ElementType;
4 import java.lang.annotation.Retention;
5 import java.lang.annotation.RetentionPolicy;
6 import java.lang.annotation.Target;
7 
8 /**
9  * Marker annotation that can be used to define a logical "any setter" mutator --
10  * either using non-static
11  * two-argument method (first argument name of property, second value
12  * to set) or a field (of type {@link java.util.Map} or POJO) -
13  * to be used as a "fallback" handler
14  * for all otherwise unrecognized properties found from JSON content.
15  * It is similar to {@code javax.xml.bind.annotation.XmlAnyElement}
16  * in behavior; and can only be used to denote a single property
17  * per type.
18  *<p>
19  * If used, all otherwise unmapped key-value pairs from JSON Object values
20  * are added using mutator.
21  *<p>
22  * NOTE: ability to annotated fields was added in version 2.8; earlier only
23  * methods could be annotated.
24  */
25 @Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD, ElementType.FIELD})
26 @Retention(RetentionPolicy.RUNTIME)
27 @JacksonAnnotation
28 public @interface JsonAnySetter
29 {
30     /**
31      * Optional argument that defines whether this annotation is active
32      * or not. The only use for value 'false' if for overriding purposes.
33      * Overriding may be necessary when used
34      * with "mix-in annotations" (aka "annotation overrides").
35      * For most cases, however, default value of "true" is just fine
36      * and should be omitted.
37      *
38      * @return True if annotation is enabled (normal case); false if it is to
39      *   be ignored (only useful for mix-in annotations to "mask" annotation)
40      *
41      * @since 2.9
42      */
enabled()43     boolean enabled() default true;
44 }
45