Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ NOTE: Jackson 3.x components rely on 2.x annotations; there are no separate

2.22 (not yet released)

#78: Add `@JsonApplyView` to allow changing active JsonView on submodels
(requested by Michael I)
(contributed by @f-aubert)
#339: Add `OptBoolean` valued property "order" in `@JsonIncludeProperties`
#342: Add `@JsonTypeInfo.writeTypeIdForDefaultImpl` to allow skipping
writing of type id for values of default type
Expand Down
41 changes: 41 additions & 0 deletions src/main/java/com/fasterxml/jackson/annotation/JsonApplyView.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
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
* the property that is defined by method or field annotated.
*<p>
* An example annotation would be:
*<pre>
* &#064;JsonApplyView(BasicView.class)
* public MyValue value;
*</pre>
* which would specify that property annotated would be processed
* using View identified by {@code BasicView.class}.
*<p>
* Note: initially processing only covers serialization.
*
* @since 2.22
*/
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@since 2.22

@Target({ElementType.ANNOTATION_TYPE,
ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@JacksonAnnotation
public @interface JsonApplyView
{
/**
* View that should be used to process annotated property, if any;
* special value {@link JsonApplyView.NONE} indicates that no View
* should used.
*/
public Class<?> value() default NONE.class;

/**
* Special view indicating no views should be used for processing annotated property.
*/
static public interface NONE {}
}