[jackson-annotations] 14/207: Add JsonTypeId, needed for proper handling of type ids during deserialization

Timo Aaltonen tjaalton at moszumanska.debian.org
Sat Sep 6 13:55:34 UTC 2014


This is an automated email from the git hooks/post-receive script.

tjaalton pushed a commit to branch master
in repository jackson-annotations.

commit 95665198d8ebd62a68209693d68c29a9f6a2aa3c
Author: Tatu <tatu at ning.com>
Date:   Fri Feb 3 14:39:21 2012 -0800

    Add JsonTypeId, needed for proper handling of type ids during deserialization
---
 .../fasterxml/jackson/annotation/JsonGetter.java   |  8 ++---
 .../fasterxml/jackson/annotation/JsonTypeId.java   | 35 ++++++++++++++++++++++
 2 files changed, 39 insertions(+), 4 deletions(-)

diff --git a/src/main/java/com/fasterxml/jackson/annotation/JsonGetter.java b/src/main/java/com/fasterxml/jackson/annotation/JsonGetter.java
index 0e14495..677b32a 100644
--- a/src/main/java/com/fasterxml/jackson/annotation/JsonGetter.java
+++ b/src/main/java/com/fasterxml/jackson/annotation/JsonGetter.java
@@ -8,9 +8,10 @@ import java.lang.annotation.Target;
 /**
  * Marker annotation that can be used to define a non-static,
  * no-argument value-returning (non-void) method to be used as a "getter"
- * for a logical property,
- * as an alternative to recommended
- * {@link JsonProperty} annotation (which was introduced in version 1.1).
+ * for a logical property.
+ * It can be used as an alternative to more general
+ * {@link JsonProperty} annotation (which is the recommended choice in
+ * general case).
  *<p>
  * Getter means that when serializing Object instance of class that has
  * this method (possibly inherited from a super class), a call is made
@@ -20,7 +21,6 @@ import java.lang.annotation.Target;
 @Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD})
 @Retention(RetentionPolicy.RUNTIME)
 @JacksonAnnotation
- at Deprecated
 public @interface JsonGetter
 {
     /**
diff --git a/src/main/java/com/fasterxml/jackson/annotation/JsonTypeId.java b/src/main/java/com/fasterxml/jackson/annotation/JsonTypeId.java
new file mode 100644
index 0000000..aa12869
--- /dev/null
+++ b/src/main/java/com/fasterxml/jackson/annotation/JsonTypeId.java
@@ -0,0 +1,35 @@
+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;
+
+/**
+ * Marker annotation that can be used on a property accessor
+ * (field, getter or setter, constructor parameter) to indicate that
+ * the property is to contain type id to use when including
+ * polymorphic type information.
+ * Annotation should <b>only be used</b> if the intent is to override
+ * generation of standard type id: if so, value of the property will be
+ * accessed during serialization and used as the type id.
+ *<p>
+ * On deserialization annotation has no effect, as visibility of type id
+ * is governed by value of {@link JsonTypeInfo#visible}; properties with
+ * this annotation get no special handling.
+ *<p>
+ * On serialization, this annotation will exclude property from being
+ * serialized along other properties; instead, its value is serialized
+ * as the type identifier. Since type identifier may be included in
+ * various places, it may still appear like 'normal' property (when using
+ * {@link JsonTypeInfo.As#PROPERTY}), but is more commonly embedded
+ * in a different place, as per inclusion rules (see {@link JsonTypeInfo}
+ * for details).
+ */
+ at Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER})
+ at Retention(RetentionPolicy.RUNTIME)
+ at JacksonAnnotation
+public @interface JsonTypeId
+{
+
+}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/jackson-annotations.git



More information about the pkg-java-commits mailing list