• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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  * Annotation used to indicate that associated property is part of
10  * two-way linkage between fields; and that its role is "child" (or "back") link.
11  * Value type of the property must be a bean: it can not be a Collection, Map,
12  * Array or enumeration.
13  * Linkage is handled such that the property
14  * annotated with this annotation is not serialized; and during deserialization,
15  * its value is set to instance that has the "managed" (forward) link.
16  *<p>
17  * All references have logical name to allow handling multiple linkages; typical case
18  * would be that where nodes have both parent/child and sibling linkages. If so,
19  * pairs of references should be named differently.
20  * It is an error for a class to have multiple back references with same name,
21  * even if types pointed are different.
22  *<p>
23  * Note: only methods and fields can be annotated with this annotation: constructor
24  * arguments should NOT be annotated, as they can not be either managed or back
25  * references.
26  */
27 @Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD, ElementType.METHOD})
28 @Retention(RetentionPolicy.RUNTIME)
29 @JacksonAnnotation
30 public @interface JsonBackReference
31 {
32     /**
33      * Logical name for the reference property pair; used to link managed and
34      * back references. Default name can be used if there is just single
35      * reference pair (for example, node class that just has parent/child linkage,
36      * consisting of one managed reference and matching back reference)
37      *
38      * @return Logical name for the reference pair
39      */
value()40     public String value() default "defaultReference";
41 }
42