xref: /aosp_15_r20/external/jackson-annotations/src/main/java/com/fasterxml/jackson/annotation/JsonTypeId.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 on a property accessor
10  * (field, getter or setter, constructor parameter) to indicate that
11  * the property is to contain type id to use when including
12  * polymorphic type information.
13  * Annotation should <b>only be used</b> if the intent is to override
14  * generation of standard type id: if so, value of the property will be
15  * accessed during serialization and used as the type id.
16  *<p>
17  * On deserialization annotation has no effect, as visibility of type id
18  * is governed by value of {@link JsonTypeInfo#visible}; properties with
19  * this annotation get no special handling.
20  *<p>
21  * On serialization, this annotation will exclude property from being
22  * serialized along other properties; instead, its value is serialized
23  * as the type identifier. Since type identifier may be included in
24  * various places, it may still appear like 'normal' property (when using
25  * {@link JsonTypeInfo.As#PROPERTY}), but is more commonly embedded
26  * in a different place, as per inclusion rules (see {@link JsonTypeInfo}
27  * for details).
28  *
29  * @since 2.0
30  */
31 @Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER})
32 @Retention(RetentionPolicy.RUNTIME)
33 @JacksonAnnotation
34 public @interface JsonTypeId
35 {
36 
37 }
38