Skip to content

Commit

Permalink
minor simplification
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Feb 26, 2017
1 parent e5e475f commit 76381c5
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 64 deletions.
26 changes: 15 additions & 11 deletions src/main/java/com/fasterxml/jackson/databind/BeanProperty.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonFormat.Value;
import com.fasterxml.jackson.annotation.JsonInclude;

import com.fasterxml.jackson.databind.cfg.MapperConfig;
import com.fasterxml.jackson.databind.introspect.AnnotatedMember;
import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonObjectFormatVisitor;
Expand Down Expand Up @@ -216,29 +217,32 @@ public static class Std implements BeanProperty,
*/
protected final AnnotatedMember _member;

/**
* Annotations defined in the context class (if any); may be null
* if no annotations were found
*/
protected final transient Annotations _contextAnnotations;

public Std(PropertyName name, JavaType type, PropertyName wrapperName,
Annotations contextAnnotations, AnnotatedMember member,
PropertyMetadata metadata)
AnnotatedMember member, PropertyMetadata metadata)
{
_name = name;
_type = type;
_wrapperName = wrapperName;
_metadata = metadata;
_member = member;
_contextAnnotations = contextAnnotations;
}

/**
* @deprecated Since 2.9
*/
@Deprecated
public Std(PropertyName name, JavaType type, PropertyName wrapperName,
Annotations contextAnnotations,
AnnotatedMember member, PropertyMetadata metadata)
{
this(name, type, wrapperName, member, metadata);
}

/**
* @since 2.6
*/
public Std(Std base, JavaType newType) {
this(base._name, newType, base._wrapperName, base._contextAnnotations, base._member, base._metadata);
this(base._name, newType, base._wrapperName, base._member, base._metadata);
}

public Std withType(JavaType type) {
Expand All @@ -252,7 +256,7 @@ public <A extends Annotation> A getAnnotation(Class<A> acls) {

@Override
public <A extends Annotation> A getContextAnnotation(Class<A> acls) {
return (_contextAnnotations == null) ? null : _contextAnnotations.get(acls);
return null;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -841,8 +841,7 @@ protected SettableBeanProperty constructCreatorProperty(DeserializationContext c
}
JavaType type = resolveMemberAndTypeAnnotations(ctxt, param, param.getType());
BeanProperty.Std property = new BeanProperty.Std(name, type,
intr.findWrapperName(param),
beanDesc.getClassAnnotations(), param, metadata);
intr.findWrapperName(param), param, metadata);
// Type deserializer: either comes from property (and already resolved)
TypeDeserializer typeDeser = (TypeDeserializer) type.getTypeHandler();
// or if not, based on type being referenced:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,8 @@ public BeanDeserializer(BeanDeserializerBase src, BeanPropertyMap props) {
@Override
public JsonDeserializer<Object> unwrappingDeserializer(NameTransformer unwrapper)
{
/* bit kludgy but we don't want to accidentally change type; sub-classes
* MUST override this method to support unwrapped properties...
*/
// bit kludgy but we don't want to accidentally change type; sub-classes
// MUST override this method to support unwrapped properties...
if (getClass() != BeanDeserializer.class) {
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,6 @@ public abstract class BeanDeserializerBase
/**********************************************************
*/

/**
* Annotations from the bean class: used for accessing
* annotations during resolution
* (see {@link #resolve}) and
* contextualization (see {@link #createContextual})
*<p>
* Transient since annotations only used during construction.
*/
final private transient Annotations _classAnnotations;

/**
* Declared type of the bean this deserializer handles.
*/
Expand Down Expand Up @@ -209,9 +199,6 @@ protected BeanDeserializerBase(BeanDeserializerBuilder builder,
boolean hasViews)
{
super(beanDesc.getType());

AnnotatedClass ac = beanDesc.getClassInfo();
_classAnnotations = ac.getAnnotations();
_beanType = beanDesc.getType();
_valueInstantiator = builder.getValueInstantiator();

Expand Down Expand Up @@ -253,7 +240,6 @@ protected BeanDeserializerBase(BeanDeserializerBase src, boolean ignoreAllUnknow
{
super(src._beanType);

_classAnnotations = src._classAnnotations;
_beanType = src._beanType;

_valueInstantiator = src._valueInstantiator;
Expand All @@ -280,7 +266,6 @@ protected BeanDeserializerBase(BeanDeserializerBase src, NameTransformer unwrapp
{
super(src._beanType);

_classAnnotations = src._classAnnotations;
_beanType = src._beanType;

_valueInstantiator = src._valueInstantiator;
Expand Down Expand Up @@ -318,8 +303,6 @@ protected BeanDeserializerBase(BeanDeserializerBase src, NameTransformer unwrapp
public BeanDeserializerBase(BeanDeserializerBase src, ObjectIdReader oir)
{
super(src._beanType);

_classAnnotations = src._classAnnotations;
_beanType = src._beanType;

_valueInstantiator = src._valueInstantiator;
Expand Down Expand Up @@ -357,20 +340,18 @@ public BeanDeserializerBase(BeanDeserializerBase src, ObjectIdReader oir)
public BeanDeserializerBase(BeanDeserializerBase src, Set<String> ignorableProps)
{
super(src._beanType);

_classAnnotations = src._classAnnotations;
_beanType = src._beanType;

_valueInstantiator = src._valueInstantiator;
_delegateDeserializer = src._delegateDeserializer;
_propertyBasedCreator = src._propertyBasedCreator;

_backRefs = src._backRefs;
_ignorableProps = ignorableProps;
_ignoreAllUnknown = src._ignoreAllUnknown;
_anySetter = src._anySetter;
_injectables = src._injectables;

_nonStandardCreation = src._nonStandardCreation;
_unwrappedPropertyHandler = src._unwrappedPropertyHandler;
_needViewProcesing = src._needViewProcesing;
Expand All @@ -390,14 +371,12 @@ public BeanDeserializerBase(BeanDeserializerBase src, Set<String> ignorableProps
protected BeanDeserializerBase(BeanDeserializerBase src, BeanPropertyMap beanProps)
{
super(src._beanType);

_classAnnotations = src._classAnnotations;
_beanType = src._beanType;

_valueInstantiator = src._valueInstantiator;
_delegateDeserializer = src._delegateDeserializer;
_propertyBasedCreator = src._propertyBasedCreator;

_beanProperties = beanProps;
_backRefs = src._backRefs;
_ignorableProps = src._ignorableProps;
Expand Down Expand Up @@ -631,7 +610,7 @@ private JsonDeserializer<Object> _findDelegateDeserializer(DeserializationContex
AnnotatedWithParams delegateCreator) throws JsonMappingException {
// Need to create a temporary property to allow contextual deserializers:
BeanProperty.Std property = new BeanProperty.Std(TEMP_PROPERTY_NAME,
delegateType, null, _classAnnotations, delegateCreator,
delegateType, null, delegateCreator,
PropertyMetadata.STD_OPTIONAL);

TypeDeserializer td = delegateType.getTypeHandler();
Expand Down Expand Up @@ -798,8 +777,7 @@ protected SettableBeanProperty _resolveManagedReferenceProperty(DeserializationC
refName, backRefType.getRawClass().getName(),
referredType.getRawClass().getName()));
}
return new ManagedReferenceProperty(prop, refName, backProp,
_classAnnotations, isContainer);
return new ManagedReferenceProperty(prop, refName, backProp, isContainer);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,7 @@ public void addInjectable(PropertyName propName, JavaType propType,
if (fixAccess) {
member.fixAccess(forceAccess);
}
_injectables.add(new ValueInjector(propName, propType,
contextAnnotations, member, valueId));
_injectables.add(new ValueInjector(propName, propType, member, valueId));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ protected SettableAnyProperty constructAnySetter(DeserializationContext ctxt,
valueType = am.getParameterType(1);
valueType = resolveMemberAndTypeAnnotations(ctxt, mutator, valueType);
prop = new BeanProperty.Std(PropertyName.construct(mutator.getName()),
valueType, null, beanDesc.getClassAnnotations(), mutator,
valueType, null, mutator,
PropertyMetadata.STD_OPTIONAL);

} else if (mutator instanceof AnnotatedField) {
Expand All @@ -691,8 +691,7 @@ protected SettableAnyProperty constructAnySetter(DeserializationContext ctxt,
keyType = mapType.getKeyType();
valueType = mapType.getContentType();
prop = new BeanProperty.Std(PropertyName.construct(mutator.getName()),
mapType, null, beanDesc.getClassAnnotations(), mutator,
PropertyMetadata.STD_OPTIONAL);
mapType, null, mutator, PropertyMetadata.STD_OPTIONAL);
} else {
return ctxt.reportBadDefinition(beanDesc.getType(), String.format(
"Unrecognized mutator type for any setter: %s", mutator.getClass()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.deser.SettableBeanProperty;
import com.fasterxml.jackson.databind.util.Annotations;

/**
* Wrapper property that is used to handle managed (forward) properties
Expand All @@ -31,7 +30,7 @@ public final class ManagedReferenceProperty
protected final SettableBeanProperty _backProperty;

public ManagedReferenceProperty(SettableBeanProperty forward, String refName,
SettableBeanProperty backward, Annotations contextAnnotations, boolean isContainer)
SettableBeanProperty backward, boolean isContainer)
{
super(forward);
_referenceName = refName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,8 @@

import java.io.IOException;

import com.fasterxml.jackson.databind.BeanProperty;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.PropertyMetadata;
import com.fasterxml.jackson.databind.PropertyName;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.introspect.AnnotatedMember;
import com.fasterxml.jackson.databind.util.Annotations;

/**
* Class that encapsulates details of value injection that occurs before
Expand All @@ -28,11 +22,9 @@ public class ValueInjector
protected final Object _valueId;

public ValueInjector(PropertyName propName, JavaType type,
Annotations contextAnnotations, AnnotatedMember mutator,
Object valueId)
AnnotatedMember mutator, Object valueId)
{
super(propName, type, null, contextAnnotations, mutator,
PropertyMetadata.STD_OPTIONAL);
super(propName, type, null, mutator, PropertyMetadata.STD_OPTIONAL);
_valueId = valueId;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ protected JsonSerializer<Object> constructBeanSerializer(SerializerProvider prov
// TODO: can we find full PropertyName?
PropertyName name = PropertyName.construct(anyGetter.getName());
BeanProperty.Std anyProp = new BeanProperty.Std(name, valueType, null,
beanDesc.getClassAnnotations(), anyGetter, PropertyMetadata.STD_OPTIONAL);
anyGetter, PropertyMetadata.STD_OPTIONAL);
builder.setAnyGetter(new AnyGetterWriter(anyProp, anyGetter, anySer));
}
// Next: need to gather view information, if any:
Expand Down Expand Up @@ -905,7 +905,7 @@ protected BeanPropertyWriter _constructWriter(SerializerProvider prov,
final PropertyName name = propDef.getFullName();
JavaType type = accessor.getType();
BeanProperty.Std property = new BeanProperty.Std(name, type, propDef.getWrapperName(),
pb.getClassAnnotations(), accessor, propDef.getMetadata());
accessor, propDef.getMetadata());

// Does member specify a serializer? If so, let's use it.
JsonSerializer<?> annotatedSerializer = findSerializerFromAnnotation(prov,
Expand Down

0 comments on commit 76381c5

Please sign in to comment.