From d107a0872243cfff04f114489e653821ef1f46de Mon Sep 17 00:00:00 2001 From: isc-auf Date: Mon, 9 Mar 2026 17:57:51 +0100 Subject: [PATCH] Fix #78: new JsonApplyView annotation --- .../jackson/annotation/JsonApplyView.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/main/java/com/fasterxml/jackson/annotation/JsonApplyView.java diff --git a/src/main/java/com/fasterxml/jackson/annotation/JsonApplyView.java b/src/main/java/com/fasterxml/jackson/annotation/JsonApplyView.java new file mode 100644 index 00000000..2a96ba8e --- /dev/null +++ b/src/main/java/com/fasterxml/jackson/annotation/JsonApplyView.java @@ -0,0 +1,34 @@ +package com.fasterxml.jackson.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Annotation used for specifying view that should be used to + * process (serialize) the property that is defined by method + * or field annotated. + *

+ * An example annotation would be: + *

+ *  @JsonApplyView(BasicView.class)
+ *
+ * which would specify that property annotated would be processed + * (serialized) using View identified by BasicView.class. + */ +@Target({ElementType.ANNOTATION_TYPE, + ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +@JacksonAnnotation +public @interface JsonApplyView { + /** + * View that should be used to serialize annotated property. + */ + public Class value() default NONE.class; + + /** + * Special view indicating no views should be used to serialize annotated property. + */ + static public interface NONE {} +}