[jackson-annotations] 04/207: Add PropertyAccessor; the replacement for 1.x "JsonMethod" enumeration

Timo Aaltonen tjaalton at moszumanska.debian.org
Sat Sep 6 13:55:33 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 3368094ca3a9e336b181a497a4697a568b9cb228
Author: Tatu Saloranta <tsaloranta at gmail.com>
Date:   Fri Dec 23 17:15:00 2011 -0800

    Add PropertyAccessor; the replacement for 1.x "JsonMethod" enumeration
---
 .../jackson/annotation/PropertyAccessor.java       | 87 ++++++++++++++++++++++
 1 file changed, 87 insertions(+)

diff --git a/src/main/java/com/fasterxml/jackson/annotation/PropertyAccessor.java b/src/main/java/com/fasterxml/jackson/annotation/PropertyAccessor.java
new file mode 100644
index 0000000..ef4b846
--- /dev/null
+++ b/src/main/java/com/fasterxml/jackson/annotation/PropertyAccessor.java
@@ -0,0 +1,87 @@
+package com.fasterxml.jackson.annotation;
+
+/**
+ * Enumeration used to define kinds of elements (called "property accessors")
+ * that annotations like {@link JsonAutoDetect} apply to.
+ *<p>
+ * In addition to method types (GETTER/IS_GETTER, SETTER, CREATOR) and the
+ * field type (FIELD), 2 pseudo-types
+ * are defined for convenience: <code>ALWAYS</code> and <code>NONE</code>. These
+ * can be used to indicate, all or none of available method types (respectively),
+ * for use by annotations that takes <code>JsonMethod</code> argument.
+ */
+public enum PropertyAccessor
+{
+    /**
+     * Getters are methods used to get a POJO field value for serialization,
+     * or, under certain conditions also for de-serialization. Latter
+     * can be used for effectively setting Collection or Map values
+     * in absence of setters, iff returned value is not a copy but
+     * actual value of the logical property.
+     *<p>
+     * Since version 1.3, this does <b>NOT</b> include "is getters" (methods
+     * that return boolean and named 'isXxx' for property 'xxx'); instead,
+     * {@link #IS_GETTER} is used}.
+     */
+    GETTER,
+
+    /**
+     * Setters are methods used to set a POJO value for deserialization.
+     */
+    SETTER,
+
+    /**
+     * Creators are constructors and (static) factory methods used to
+     * construct POJO instances for deserialization
+     */
+    CREATOR,
+
+    /**
+     * Field refers to fields of regular Java objects. Although
+     * they are not really methods, addition of optional field-discovery
+     * in version 1.1 meant that there was need to enable/disable
+     * their auto-detection, and this is the place to add it in.
+     */
+    FIELD,
+
+    /**
+     * "Is getters" are getter-like methods that are named "isXxx"
+     * (instead of "getXxx" for getters) and return boolean value
+     * (either primitive, or {@link java.lang.Boolean}).
+     *
+     */
+    IS_GETTER,
+
+    /**
+     * This pseudo-type indicates that none of accessors if affected.
+     */
+    NONE,
+
+    /**
+     * This pseudo-type indicates that all accessors are affected.
+     */
+    ALL
+    ;
+
+    private PropertyAccessor() { }
+
+    public boolean creatorEnabled() {
+        return (this == CREATOR) || (this == ALL);
+    }
+
+    public boolean getterEnabled() {
+        return (this == GETTER) || (this == ALL);
+    }
+
+    public boolean isGetterEnabled() {
+        return (this == IS_GETTER) || (this == ALL);
+    }
+
+    public boolean setterEnabled() {
+        return (this == SETTER) || (this == ALL);
+    }
+
+    public boolean fieldEnabled() {
+        return (this == FIELD) || (this == ALL);
+    }
+}

-- 
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