aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializerBase.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializerBase.java')
-rw-r--r--src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializerBase.java122
1 files changed, 60 insertions, 62 deletions
diff --git a/src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializerBase.java b/src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializerBase.java
index 87b05c90c..537126603 100644
--- a/src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializerBase.java
+++ b/src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializerBase.java
@@ -360,15 +360,11 @@ public abstract class BeanDeserializerBase
}
}
- public BeanDeserializerBase(BeanDeserializerBase src, Set<String> ignorableProps)
- {
- this(src, ignorableProps, src._includableProps);
- }
-
/**
* @since 2.12
*/
- public BeanDeserializerBase(BeanDeserializerBase src, Set<String> ignorableProps, Set<String> includableProps)
+ public BeanDeserializerBase(BeanDeserializerBase src,
+ Set<String> ignorableProps, Set<String> includableProps)
{
super(src._beanType);
_beanType = src._beanType;
@@ -397,7 +393,6 @@ public abstract class BeanDeserializerBase
_beanProperties = src._beanProperties.withoutProperties(ignorableProps, includableProps);
}
-
/**
* @since 2.8
*/
@@ -426,39 +421,27 @@ public abstract class BeanDeserializerBase
_vanillaProcessing = src._vanillaProcessing;
}
+
+ @Deprecated // since 2.12
+ protected BeanDeserializerBase(BeanDeserializerBase src, Set<String> ignorableProps)
+ {
+ this(src, ignorableProps, src._includableProps);
+ }
@Override
public abstract JsonDeserializer<Object> unwrappingDeserializer(NameTransformer unwrapper);
public abstract BeanDeserializerBase withObjectIdReader(ObjectIdReader oir);
- public BeanDeserializerBase withIgnorableProperties(Set<String> ignorableProps) {
- return withIgnorableProperties(ignorableProps, _includableProps);
- }
-
/**
* @since 2.12
*/
- public abstract BeanDeserializerBase withIgnorableProperties(Set<String> ignorableProps, Set<String> includableProps);
+ public abstract BeanDeserializerBase withByNameInclusion(Set<String> ignorableProps, Set<String> includableProps);
/**
- * @since 2.12
- */
- public BeanDeserializerBase withIncludableProperties(Set<String> includableProperties) {
- return withIgnorableProperties(_ignorableProps, includableProperties);
- }
-
- // NOTE! To be made `abstract` in 2.12 or later
- /**
* @since 2.11
*/
- public BeanDeserializerBase withIgnoreAllUnknown(boolean ignoreUnknown) {
- // Only to prevent some backwards-compatibility issues
- if (ignoreUnknown == _ignoreAllUnknown) {
- return this;
- }
- return withIgnorableProperties(_ignorableProps, _includableProps);
- }
+ public abstract BeanDeserializerBase withIgnoreAllUnknown(boolean ignoreUnknown);
/**
* Mutant factory method that custom sub-classes must override; not left as
@@ -480,6 +463,14 @@ public abstract class BeanDeserializerBase
*/
protected abstract BeanDeserializerBase asArrayDeserializer();
+ /**
+ * @deprecated Since 2.12 use {@link #withByNameInclusion} instead
+ */
+ @Deprecated
+ public BeanDeserializerBase withIgnorableProperties(Set<String> ignorableProps) {
+ return withByNameInclusion(ignorableProps, _includableProps);
+ }
+
/*
/**********************************************************
/* Validation, post-processing
@@ -789,41 +780,7 @@ public abstract class BeanDeserializerBase
}
// And possibly add more properties to ignore
if (accessor != null) {
- final DeserializationConfig config = ctxt.getConfig();
- JsonIgnoreProperties.Value ignorals = intr.findPropertyIgnoralByName(config, accessor);
- if (ignorals != null) {
- Set<String> ignored = ignorals.findIgnoredForDeserialization();
- if (!ignored.isEmpty()) {
- Set<String> prev = contextual._ignorableProps;
- if ((prev != null) && !prev.isEmpty()) {
- ignored = new HashSet<String>(ignored);
- ignored.addAll(prev);
- }
- contextual = contextual.withIgnorableProperties(ignored);
- }
- // 30-Mar-2020, tatu: As per [databind#2627], need to also allow
- // per-property override to "ignore all unknown".
- // NOTE: there is no way to override with `false` because annotation
- // defaults to `false` (i.e. can not know if `false` is explicit value)
- if (ignorals.getIgnoreUnknown() && !_ignoreAllUnknown) {
- contextual = contextual.withIgnoreAllUnknown(true);
- }
- }
- JsonIncludeProperties.Value inclusions = intr.findPropertyInclusionByName(config, accessor);
- if (inclusions != null) {
- Set<String> included = inclusions.getIncluded();
- Set<String> prev = contextual._includableProps;
- if (prev != null && included != null) {
- Set<String> newIncluded = new HashSet<>();
- // Make the intersection with the previously included properties.
- for(String prop : prev) {
- if (included.contains(prop)) {
- newIncluded.add(prop);
- }
- }
- contextual = contextual.withIncludableProperties(newIncluded);
- }
- }
+ contextual = _handleByNameInclusion(ctxt, intr, contextual, accessor);
}
// One more thing: are we asked to serialize POJO as array?
@@ -853,6 +810,47 @@ public abstract class BeanDeserializerBase
return contextual;
}
+ // @since 2.12
+ protected BeanDeserializerBase _handleByNameInclusion(DeserializationContext ctxt,
+ AnnotationIntrospector intr,
+ BeanDeserializerBase contextual,
+ AnnotatedMember accessor) throws JsonMappingException
+ {
+ final DeserializationConfig config = ctxt.getConfig();
+ JsonIgnoreProperties.Value ignorals = intr.findPropertyIgnoralByName(config, accessor);
+
+ // 30-Mar-2020, tatu: As per [databind#2627], need to also allow
+ // per-property override to "ignore all unknown".
+ // NOTE: there is no way to override with `false` because annotation
+ // defaults to `false` (i.e. can not know if `false` is explicit value)
+ if (ignorals.getIgnoreUnknown() && !_ignoreAllUnknown) {
+ contextual = contextual.withIgnoreAllUnknown(true);
+ }
+
+ final Set<String> namesToIgnore = ignorals.findIgnoredForDeserialization();
+ final Set<String> prevNamesToIgnore = contextual._ignorableProps;
+ final Set<String> newNamesToIgnore;
+
+ if (namesToIgnore.isEmpty()) {
+ newNamesToIgnore = prevNamesToIgnore;
+ } else if ((prevNamesToIgnore == null) || prevNamesToIgnore.isEmpty()) {
+ newNamesToIgnore = namesToIgnore;
+ } else {
+ newNamesToIgnore = new HashSet<String>(prevNamesToIgnore);
+ newNamesToIgnore.addAll(namesToIgnore);
+ }
+
+ final Set<String> prevNamesToInclude = contextual._includableProps;
+ final Set<String> newNamesToInclude = IgnorePropertiesUtil.combineNamesToInclude(prevNamesToInclude,
+ intr.findPropertyInclusionByName(config, accessor).getIncluded());
+
+ if ((newNamesToIgnore != prevNamesToIgnore)
+ || (newNamesToInclude != prevNamesToInclude)) {
+ contextual = contextual.withByNameInclusion(newNamesToIgnore, newNamesToInclude);
+ }
+ return contextual;
+ }
+
/**
* Helper method called to see if given property is part of 'managed' property
* pair (managed + back reference), and if so, handle resolution details.