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 annotated property is part of 10 * two-way linkage between fields; and that its role is "parent" (or "forward") link. 11 * Value type (class) of property must have a single compatible property annotated with 12 * {@link JsonBackReference}. Linkage is handled such that the property 13 * annotated with this annotation is handled normally (serialized normally, no 14 * special handling for deserialization); it is the matching back reference 15 * that requires special handling 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 too have multiple managed 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 * @author tatu 28 */ 29 @Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD, ElementType.METHOD}) 30 @Retention(RetentionPolicy.RUNTIME) 31 @JacksonAnnotation 32 public @interface JsonManagedReference 33 { 34 /** 35 * Logical have for the reference property pair; used to link managed and 36 * back references. Default name can be used if there is just single 37 * reference pair (for example, node class that just has parent/child linkage, 38 * consisting of one managed reference and matching back reference) 39 */ value()40 public String value() default "defaultReference"; 41 } 42