minor work towards using the new read-only/write-only/read-write access mode indicator
diff --git a/src/main/java/com/fasterxml/jackson/databind/introspect/BasicBeanDescription.java b/src/main/java/com/fasterxml/jackson/databind/introspect/BasicBeanDescription.java
index 590a1a4..9f97ebe 100644
--- a/src/main/java/com/fasterxml/jackson/databind/introspect/BasicBeanDescription.java
+++ b/src/main/java/com/fasterxml/jackson/databind/introspect/BasicBeanDescription.java
@@ -16,9 +16,12 @@
import com.fasterxml.jackson.databind.util.Converter;
/**
- * Default {@link BeanDescription} implementation.
- * Can theoretically be subclassed to customize
- * some aspects of property introspection.
+ * Default {@link BeanDescription} implementation used by Jackson.
+ *<p>
+ * Although sub-classing is a theoretical possibility there are no known
+ * use cases for that, nor is such usage tested or supported.
+ * Separation from API is mostly to isolate some implementation details
+ * here and keep API simple.
*/
public class BasicBeanDescription extends BeanDescription
{
diff --git a/src/main/java/com/fasterxml/jackson/databind/introspect/BeanPropertyDefinition.java b/src/main/java/com/fasterxml/jackson/databind/introspect/BeanPropertyDefinition.java
index eacb0fd..ca99f18 100644
--- a/src/main/java/com/fasterxml/jackson/databind/introspect/BeanPropertyDefinition.java
+++ b/src/main/java/com/fasterxml/jackson/databind/introspect/BeanPropertyDefinition.java
@@ -3,6 +3,7 @@
import java.util.Iterator;
import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.util.EmptyIterator;
import com.fasterxml.jackson.databind.util.Named;
@@ -233,4 +234,14 @@
public JsonInclude.Include findInclusion() {
return null;
}
+
+ /**
+ * Method used for checking if the logical property should have explicitly
+ * specified access with respect to read/write access (accessor/mutator).
+ *
+ * @since 2.6
+ */
+ public JsonProperty.Access findAccess() {
+ return null;
+ }
}
diff --git a/src/main/java/com/fasterxml/jackson/databind/introspect/JacksonAnnotationIntrospector.java b/src/main/java/com/fasterxml/jackson/databind/introspect/JacksonAnnotationIntrospector.java
index d4213d2..912e41a 100644
--- a/src/main/java/com/fasterxml/jackson/databind/introspect/JacksonAnnotationIntrospector.java
+++ b/src/main/java/com/fasterxml/jackson/databind/introspect/JacksonAnnotationIntrospector.java
@@ -470,7 +470,6 @@
}
JsonSerialize ann = _findAnnotation(a, JsonSerialize.class);
if (ann != null) {
- @SuppressWarnings("deprecation")
JsonSerialize.Inclusion i2 = ann.include();
switch (i2) {
case ALWAYS:
diff --git a/src/main/java/com/fasterxml/jackson/databind/introspect/POJOPropertiesCollector.java b/src/main/java/com/fasterxml/jackson/databind/introspect/POJOPropertiesCollector.java
index a7d8d11..b1cb569 100644
--- a/src/main/java/com/fasterxml/jackson/databind/introspect/POJOPropertiesCollector.java
+++ b/src/main/java/com/fasterxml/jackson/databind/introspect/POJOPropertiesCollector.java
@@ -238,7 +238,7 @@
public POJOPropertiesCollector collect()
{
_properties.clear();
-
+
// First: gather basic data
_addFields();
_addMethods();
@@ -283,94 +283,6 @@
/*
/**********************************************************
- /* Overridable internal methods, sorting, other stuff
- /**********************************************************
- */
-
- /* First, order by [JACKSON-90] (explicit ordering and/or alphabetic)
- * and then for [JACKSON-170] (implicitly order creator properties before others)
- */
- protected void _sortProperties()
- {
- // Then how about explicit ordering?
- AnnotationIntrospector intr = _annotationIntrospector;
- boolean sort;
- Boolean alpha = (intr == null) ? null : intr.findSerializationSortAlphabetically((Annotated) _classDef);
-
- if (alpha == null) {
- sort = _config.shouldSortPropertiesAlphabetically();
- } else {
- sort = alpha.booleanValue();
- }
- String[] propertyOrder = (intr == null) ? null : intr.findSerializationPropertyOrder(_classDef);
-
- // no sorting? no need to shuffle, then
- if (!sort && (_creatorProperties == null) && (propertyOrder == null)) {
- return;
- }
- int size = _properties.size();
- Map<String, POJOPropertyBuilder> all;
- // Need to (re)sort alphabetically?
- if (sort) {
- all = new TreeMap<String,POJOPropertyBuilder>();
- } else {
- all = new LinkedHashMap<String,POJOPropertyBuilder>(size+size);
- }
-
- for (POJOPropertyBuilder prop : _properties.values()) {
- all.put(prop.getName(), prop);
- }
- Map<String,POJOPropertyBuilder> ordered = new LinkedHashMap<String,POJOPropertyBuilder>(size+size);
- // Ok: primarily by explicit order
- if (propertyOrder != null) {
- for (String name : propertyOrder) {
- POJOPropertyBuilder w = all.get(name);
- if (w == null) { // also, as per [JACKSON-268], we will allow use of "implicit" names
- for (POJOPropertyBuilder prop : _properties.values()) {
- if (name.equals(prop.getInternalName())) {
- w = prop;
- // plus re-map to external name, to avoid dups:
- name = prop.getName();
- break;
- }
- }
- }
- if (w != null) {
- ordered.put(name, w);
- }
- }
- }
- // And secondly by sorting Creator properties before other unordered properties
- if (_creatorProperties != null) {
- /* As per [Issue#311], this is bit delicate; but if alphabetic ordering
- * is mandated, at least ensure creator properties are in alphabetic
- * order. Related question of creator vs non-creator is punted for now,
- * so creator properties still fully predate non-creator ones.
- */
- Collection<POJOPropertyBuilder> cr;
- if (sort) {
- TreeMap<String, POJOPropertyBuilder> sorted =
- new TreeMap<String,POJOPropertyBuilder>();
- for (POJOPropertyBuilder prop : _creatorProperties) {
- sorted.put(prop.getName(), prop);
- }
- cr = sorted.values();
- } else {
- cr = _creatorProperties;
- }
- for (POJOPropertyBuilder prop : cr) {
- ordered.put(prop.getName(), prop);
- }
- }
- // And finally whatever is left (trying to put again will not change ordering)
- ordered.putAll(all);
-
- _properties.clear();
- _properties.putAll(ordered);
- }
-
- /*
- /**********************************************************
/* Overridable internal methods, adding members
/**********************************************************
*/
@@ -891,8 +803,95 @@
}
}
}
+
+ /*
+ /**********************************************************
+ /* Overridable internal methods, sorting, other stuff
+ /**********************************************************
+ */
-
+ /* First, order by [JACKSON-90] (explicit ordering and/or alphabetic)
+ * and then for [JACKSON-170] (implicitly order creator properties before others)
+ */
+ protected void _sortProperties()
+ {
+ // Then how about explicit ordering?
+ AnnotationIntrospector intr = _annotationIntrospector;
+ boolean sort;
+ Boolean alpha = (intr == null) ? null : intr.findSerializationSortAlphabetically((Annotated) _classDef);
+
+ if (alpha == null) {
+ sort = _config.shouldSortPropertiesAlphabetically();
+ } else {
+ sort = alpha.booleanValue();
+ }
+ String[] propertyOrder = (intr == null) ? null : intr.findSerializationPropertyOrder(_classDef);
+
+ // no sorting? no need to shuffle, then
+ if (!sort && (_creatorProperties == null) && (propertyOrder == null)) {
+ return;
+ }
+ int size = _properties.size();
+ Map<String, POJOPropertyBuilder> all;
+ // Need to (re)sort alphabetically?
+ if (sort) {
+ all = new TreeMap<String,POJOPropertyBuilder>();
+ } else {
+ all = new LinkedHashMap<String,POJOPropertyBuilder>(size+size);
+ }
+
+ for (POJOPropertyBuilder prop : _properties.values()) {
+ all.put(prop.getName(), prop);
+ }
+ Map<String,POJOPropertyBuilder> ordered = new LinkedHashMap<String,POJOPropertyBuilder>(size+size);
+ // Ok: primarily by explicit order
+ if (propertyOrder != null) {
+ for (String name : propertyOrder) {
+ POJOPropertyBuilder w = all.get(name);
+ if (w == null) { // also, as per [JACKSON-268], we will allow use of "implicit" names
+ for (POJOPropertyBuilder prop : _properties.values()) {
+ if (name.equals(prop.getInternalName())) {
+ w = prop;
+ // plus re-map to external name, to avoid dups:
+ name = prop.getName();
+ break;
+ }
+ }
+ }
+ if (w != null) {
+ ordered.put(name, w);
+ }
+ }
+ }
+ // And secondly by sorting Creator properties before other unordered properties
+ if (_creatorProperties != null) {
+ /* As per [Issue#311], this is bit delicate; but if alphabetic ordering
+ * is mandated, at least ensure creator properties are in alphabetic
+ * order. Related question of creator vs non-creator is punted for now,
+ * so creator properties still fully predate non-creator ones.
+ */
+ Collection<POJOPropertyBuilder> cr;
+ if (sort) {
+ TreeMap<String, POJOPropertyBuilder> sorted =
+ new TreeMap<String,POJOPropertyBuilder>();
+ for (POJOPropertyBuilder prop : _creatorProperties) {
+ sorted.put(prop.getName(), prop);
+ }
+ cr = sorted.values();
+ } else {
+ cr = _creatorProperties;
+ }
+ for (POJOPropertyBuilder prop : cr) {
+ ordered.put(prop.getName(), prop);
+ }
+ }
+ // And finally whatever is left (trying to put again will not change ordering)
+ ordered.putAll(all);
+
+ _properties.clear();
+ _properties.putAll(ordered);
+ }
+
/*
/**********************************************************
/* Internal methods; helpers
diff --git a/src/main/java/com/fasterxml/jackson/databind/introspect/POJOPropertyBuilder.java b/src/main/java/com/fasterxml/jackson/databind/introspect/POJOPropertyBuilder.java
index 70cfed2..b9b909c 100644
--- a/src/main/java/com/fasterxml/jackson/databind/introspect/POJOPropertyBuilder.java
+++ b/src/main/java/com/fasterxml/jackson/databind/introspect/POJOPropertyBuilder.java
@@ -3,6 +3,7 @@
import java.util.*;
import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.util.EmptyIterator;
@@ -537,6 +538,16 @@
return _annotationIntrospector.findSerializationInclusion(am, null);
}
+ @Override
+ public JsonProperty.Access findAccess() {
+ return fromMemberAnnotationsExcept(new WithMember<JsonProperty.Access>() {
+ @Override
+ public JsonProperty.Access withMember(AnnotatedMember member) {
+ return _annotationIntrospector.findPropertyAccess(member);
+ }
+ }, JsonProperty.Access.AUTO);
+ }
+
/*
/**********************************************************
/* Data aggregation
@@ -913,6 +924,40 @@
}
return result;
}
+
+ protected <T> T fromMemberAnnotationsExcept(WithMember<T> func, T defaultValue)
+ {
+ if (_annotationIntrospector != null) {
+ if (_forSerialization) {
+ if (_getters != null) {
+ T result = func.withMember(_getters.value);
+ if ((result != null) && (result != defaultValue)) {
+ return result;
+ }
+ }
+ } else {
+ if (_ctorParameters != null) {
+ T result = func.withMember(_ctorParameters.value);
+ if ((result != null) && (result != defaultValue)) {
+ return result;
+ }
+ }
+ if (_setters != null) {
+ T result = func.withMember(_setters.value);
+ if ((result != null) && (result != defaultValue)) {
+ return result;
+ }
+ }
+ }
+ if (_fields != null) {
+ T result = func.withMember(_fields.value);
+ if ((result != null) && (result != defaultValue)) {
+ return result;
+ }
+ }
+ }
+ return null;
+ }
/*
/**********************************************************