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 * Optional annotation that can be used for customizing details of a reference 10 * to Objects for which "Object Identity" is enabled (see {@link JsonIdentityInfo}). 11 * The main use case is that of enforcing use of Object Id even for the first 12 * time an Object is referenced, instead of first instance being serialized 13 * as full POJO. 14 * 15 * @since 2.1 16 */ 17 @Target({ElementType.ANNOTATION_TYPE, ElementType.TYPE, 18 ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER}) 19 @Retention(RetentionPolicy.RUNTIME) 20 @JacksonAnnotation 21 public @interface JsonIdentityReference 22 { 23 /** 24 * Marker to indicate whether all referenced values are to 25 * be serialized as ids (true); or by serializing the 26 * first encountered reference as POJO and only then as id (false). 27 *<p> 28 * Note that if value of 'true' is used, deserialization may require 29 * additional contextual information, and possibly using a custom 30 * id resolver -- the default handling may not be sufficient. 31 * 32 * @since 2.1 33 */ alwaysAsId()34 public boolean alwaysAsId() default false; 35 } 36