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 import com.fasterxml.jackson.annotation.JacksonAnnotation; 9 10 /** 11 * Annotation used for indicating view(s) that the property 12 * that is defined by method or field annotated is part of. 13 *<p> 14 * An example annotation would be: 15 *<pre> 16 * @JsonView(BasicView.class) 17 *</pre> 18 * which would specify that property annotated would be included 19 * when processing (serializing, deserializing) View identified 20 * by <code>BasicView.class</code> (or its sub-class). 21 * If multiple View class identifiers are included, property will 22 * be part of all of them. 23 *<p> 24 * Starting with 2.9, it is also possible to use this annotation on 25 * POJO classes to indicate the default view(s) for properties of the 26 * type, unless overridden by per-property annotation. 27 */ 28 @Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD, ElementType.FIELD, 29 ElementType.PARAMETER, // since 2.5 30 ElementType.TYPE // since 2.9, to indicate "default view" for properties 31 }) 32 @Retention(RetentionPolicy.RUNTIME) 33 @JacksonAnnotation 34 public @interface JsonView { 35 /** 36 * View or views that annotated element is part of. Views are identified 37 * by classes, and use expected class inheritance relationship: child 38 * views contain all elements parent views have, for example. 39 */ value()40 public Class<?>[] value() default { }; 41 } 42