private AnnotatedType getInputFieldType(AnnotatedType type, BeanPropertyDefinition propertyDefinition) { AnnotatedParameter ctorParam = propertyDefinition.getConstructorParameter(); if (ctorParam != null) { Constructor<?> constructor = (Constructor<?>) ctorParam.getOwner().getMember(); return ClassUtils.getParameterTypes(constructor, type)[ctorParam.getIndex()]; } if (propertyDefinition.getSetter() != null) { return ClassUtils.getParameterTypes(propertyDefinition.getSetter().getAnnotated(), type)[0]; } if (propertyDefinition.getGetter() != null) { return ClassUtils.getReturnType(propertyDefinition.getGetter().getAnnotated(), type); } if (propertyDefinition.getField() != null) { return ClassUtils.getFieldType(propertyDefinition.getField().getAnnotated(), type); } throw new UnsupportedOperationException("Unknown input field mapping style encountered"); }
public PropertyName findNameForDeserialization(Annotated paramAnnotated) { String str; if ((paramAnnotated instanceof AnnotatedField)) str = findDeserializationName((AnnotatedField)paramAnnotated); else if ((paramAnnotated instanceof AnnotatedMethod)) str = findDeserializationName((AnnotatedMethod)paramAnnotated); else if ((paramAnnotated instanceof AnnotatedParameter)) str = findDeserializationName((AnnotatedParameter)paramAnnotated); else str = null; if (str != null) { if (str.length() == 0) return PropertyName.USE_DEFAULT; return new PropertyName(str); } return null; }
private void addJacksonAnnotationsToConstructorParameter(Field field, AnnotatedParameter parameter, String name) { if (field != null) { for (Annotation a : field.getAnnotations()) { if (a.annotationType().getName().startsWith("com.fasterxml")) { if (a.annotationType() != JsonProperty.class) { parameter.addOrOverride(a); } else { JsonProperty jp = (JsonProperty) a; if (!jp.value().equals("")) { name = jp.value(); } } } } } JsonProperty jsonProperty = ProxyAnnotation.of(JsonProperty.class, Collections.singletonMap("value", name)); parameter.addOrOverride(jsonProperty); }
@Override public String nameForConstructorParameter(MapperConfig<?> config, AnnotatedParameter ctorParam, String defaultName) { if (ctorParam.getDeclaringClass() != effectiveType) { return fieldToJsonMapping .getOrDefault(defaultName, super.nameForConstructorParameter(config, ctorParam, defaultName)); } else { return super.nameForConstructorParameter(config, ctorParam, defaultName); } }
protected CreatorProperty constructCreatorProperty(DeserializationContext paramDeserializationContext, BeanDescription paramBeanDescription, String paramString, int paramInt, AnnotatedParameter paramAnnotatedParameter, Object paramObject) { DeserializationConfig localDeserializationConfig = paramDeserializationContext.getConfig(); AnnotationIntrospector localAnnotationIntrospector = paramDeserializationContext.getAnnotationIntrospector(); Boolean localBoolean1; if (localAnnotationIntrospector == null) localBoolean1 = null; else localBoolean1 = localAnnotationIntrospector.hasRequiredMarker(paramAnnotatedParameter); Boolean localBoolean2 = localBoolean1; boolean bool1; if (localBoolean1 == null) bool1 = false; else bool1 = localBoolean2.booleanValue(); JavaType localJavaType1 = localDeserializationConfig.getTypeFactory().constructType(paramAnnotatedParameter.getParameterType(), paramBeanDescription.bindingsForBeanType()); BeanProperty.Std localStd = new BeanProperty.Std(paramString, localJavaType1, localAnnotationIntrospector.findWrapperName(paramAnnotatedParameter), paramBeanDescription.getClassAnnotations(), paramAnnotatedParameter, bool1); JavaType localJavaType2 = resolveType(paramDeserializationContext, paramBeanDescription, localJavaType1, paramAnnotatedParameter); if (localJavaType2 != localJavaType1) localStd = localStd.withType(localJavaType2); JsonDeserializer localJsonDeserializer = findDeserializerFromAnnotation(paramDeserializationContext, paramAnnotatedParameter); JavaType localJavaType3 = modifyTypeByAnnotation(paramDeserializationContext, paramAnnotatedParameter, localJavaType2); TypeDeserializer localTypeDeserializer1 = (TypeDeserializer)localJavaType3.getTypeHandler(); TypeDeserializer localTypeDeserializer2 = localTypeDeserializer1; if (localTypeDeserializer1 == null) localTypeDeserializer2 = findTypeDeserializer(localDeserializationConfig, localJavaType3); PropertyName localPropertyName = localStd.getWrapperName(); Annotations localAnnotations = paramBeanDescription.getClassAnnotations(); boolean bool2 = localStd.isRequired(); CreatorProperty localCreatorProperty = new CreatorProperty(paramString, localJavaType3, localPropertyName, localTypeDeserializer2, localAnnotations, paramAnnotatedParameter, paramInt, paramObject, bool2); if (localJsonDeserializer != null) localCreatorProperty = localCreatorProperty.withValueDeserializer(localJsonDeserializer); return localCreatorProperty; }
public ValueInstantiator findValueInstantiator(DeserializationContext paramDeserializationContext, BeanDescription paramBeanDescription) { DeserializationConfig localDeserializationConfig = paramDeserializationContext.getConfig(); AnnotatedClass localAnnotatedClass = paramBeanDescription.getClassInfo(); Object localObject1 = paramDeserializationContext.getAnnotationIntrospector().findValueInstantiator(localAnnotatedClass); Object localObject2 = null; if (localObject1 != null) localObject2 = _valueInstantiatorInstance(localDeserializationConfig, localAnnotatedClass, localObject1); if (localObject2 == null) { ValueInstantiator localValueInstantiator2 = _findStdValueInstantiator(localDeserializationConfig, paramBeanDescription); localObject2 = localValueInstantiator2; if (localValueInstantiator2 == null) localObject2 = _constructDefaultValueInstantiator(paramDeserializationContext, paramBeanDescription); } if (this._factoryConfig.hasValueInstantiators()) { Iterator localIterator = this._factoryConfig.valueInstantiators().iterator(); while (localIterator.hasNext()) { ValueInstantiators localValueInstantiators = (ValueInstantiators)localIterator.next(); ValueInstantiator localValueInstantiator1 = localValueInstantiators.findValueInstantiator(localDeserializationConfig, paramBeanDescription, (ValueInstantiator)localObject2); localObject2 = localValueInstantiator1; if (localValueInstantiator1 == null) throw new JsonMappingException("Broken registered ValueInstantiators (of type " + localValueInstantiators.getClass().getName() + "): returned null ValueInstantiator"); } } if (((ValueInstantiator)localObject2).getIncompleteParameter() != null) { AnnotatedParameter localAnnotatedParameter = ((ValueInstantiator)localObject2).getIncompleteParameter(); AnnotatedWithParams localAnnotatedWithParams = localAnnotatedParameter.getOwner(); throw new IllegalArgumentException("Argument #" + localAnnotatedParameter.getIndex() + " of constructor " + localAnnotatedWithParams + " has no property name annotation; must have name when multiple-paramater constructor annotated as Creator"); } return localObject2; }
public CreatorProperty(String paramString, JavaType paramJavaType, PropertyName paramPropertyName, TypeDeserializer paramTypeDeserializer, Annotations paramAnnotations, AnnotatedParameter paramAnnotatedParameter, int paramInt, Object paramObject, boolean paramBoolean) { super(paramString, paramJavaType, paramPropertyName, paramTypeDeserializer, paramAnnotations, paramBoolean); this._annotated = paramAnnotatedParameter; this._creatorIndex = paramInt; this._injectableValueId = paramObject; }
public AnnotatedMember getMutator() { AnnotatedParameter localAnnotatedParameter = getConstructorParameter(); Object localObject = localAnnotatedParameter; if (localAnnotatedParameter == null) { AnnotatedMethod localAnnotatedMethod = getSetter(); localObject = localAnnotatedMethod; if (localAnnotatedMethod == null) localObject = getField(); } return localObject; }
@Override public String findImplicitPropertyName(final AnnotatedMember member) { final AutoMatter.Field field = member.getAnnotation(AutoMatter.Field.class); if (field == null) { return null; } if (member instanceof AnnotatedParameter) { return field.value(); } if (member instanceof AnnotatedMethod) { return member.getName(); } return null; }
private void addJacksonAnnotationsToContructorParameters(AnnotatedConstructor annotatedConstructor) { ConstructorProperties properties = getConstructorPropertiesAnnotation(annotatedConstructor); for (int i = 0; i < annotatedConstructor.getParameterCount(); i++) { String name = properties.value()[i]; AnnotatedParameter parameter = annotatedConstructor.getParameter(i); Field field = null; try { field = annotatedConstructor.getDeclaringClass().getDeclaredField(name); } catch (NoSuchFieldException ignored) { } addJacksonAnnotationsToConstructorParameter(field, parameter, name); } }
private void addMethod(Method method) { FunctionType function = new FunctionType(); AnnotatedMethod annotMethod = new AnnotatedMethod(null, method, new AnnotationMap(), null); function.setResultType(getTSTypeForClass(annotMethod)); for (int i = 0; i < annotMethod.getParameterCount(); i++) { AnnotatedParameter param = annotMethod.getParameter(i); String name = "param" + i; function.getParameters().put(name, getTSTypeForClass(param)); } this.type.getMethods().put(method.getName(), function); }
@Override public String nameForConstructorParameter(MapperConfig<?> config, AnnotatedParameter ctorParam, String defaultName) { String name = config instanceof DeserializationConfig? jsonldName(ctorParam): null; return Optional.ofNullable(name).orElse(super.nameForConstructorParameter(config, ctorParam, defaultName)); }
protected void _addDeserializerFactoryMethods(DeserializationContext paramDeserializationContext, BeanDescription paramBeanDescription, VisibilityChecker<?> paramVisibilityChecker, AnnotationIntrospector paramAnnotationIntrospector, CreatorCollector paramCreatorCollector) { DeserializationConfig localDeserializationConfig = paramDeserializationContext.getConfig(); Iterator localIterator = paramBeanDescription.getFactoryMethods().iterator(); while (localIterator.hasNext()) { AnnotatedMethod localAnnotatedMethod = (AnnotatedMethod)localIterator.next(); boolean bool = paramAnnotationIntrospector.hasCreatorAnnotation(localAnnotatedMethod); int i = localAnnotatedMethod.getParameterCount(); if (i == 0) { if (bool) paramCreatorCollector.setDefaultCreator(localAnnotatedMethod); } else if (i == 1) { AnnotatedParameter localAnnotatedParameter2 = localAnnotatedMethod.getParameter(0); PropertyName localPropertyName3; if (localAnnotatedParameter2 == null) localPropertyName3 = null; else localPropertyName3 = paramAnnotationIntrospector.findNameForDeserialization(localAnnotatedParameter2); PropertyName localPropertyName4 = localPropertyName3; String str2; if (localPropertyName3 == null) str2 = null; else str2 = localPropertyName4.getSimpleName(); if ((paramAnnotationIntrospector.findInjectableValueId(localAnnotatedParameter2) == null) && ((str2 == null) || (str2.length() == 0))) _handleSingleArgumentFactory(localDeserializationConfig, paramBeanDescription, paramVisibilityChecker, paramAnnotationIntrospector, paramCreatorCollector, localAnnotatedMethod, bool); else; } else if (paramAnnotationIntrospector.hasCreatorAnnotation(localAnnotatedMethod)) { Object localObject1 = null; CreatorProperty[] arrayOfCreatorProperty = new CreatorProperty[i]; int j = 0; int k = 0; for (int m = 0; m < i; m++) { AnnotatedParameter localAnnotatedParameter1 = localAnnotatedMethod.getParameter(m); PropertyName localPropertyName1; if (localAnnotatedParameter1 == null) localPropertyName1 = null; else localPropertyName1 = paramAnnotationIntrospector.findNameForDeserialization(localAnnotatedParameter1); PropertyName localPropertyName2 = localPropertyName1; String str1; if (localPropertyName1 == null) str1 = null; else str1 = localPropertyName2.getSimpleName(); Object localObject2 = paramAnnotationIntrospector.findInjectableValueId(localAnnotatedParameter1); if ((str1 != null) && (str1.length() > 0)) { j++; arrayOfCreatorProperty[m] = constructCreatorProperty(paramDeserializationContext, paramBeanDescription, str1, m, localAnnotatedParameter1, localObject2); } else if (localObject2 != null) { k++; arrayOfCreatorProperty[m] = constructCreatorProperty(paramDeserializationContext, paramBeanDescription, str1, m, localAnnotatedParameter1, localObject2); } else if (localObject1 == null) { localObject1 = localAnnotatedParameter1; } } if ((bool) || (j > 0) || (k > 0)) if (j + k == i) paramCreatorCollector.addPropertyCreator(localAnnotatedMethod, arrayOfCreatorProperty); else if ((j == 0) && (k + 1 == i)) paramCreatorCollector.addDelegatingCreator(localAnnotatedMethod, arrayOfCreatorProperty); else throw new IllegalArgumentException("Argument #" + localObject1.getIndex() + " of factory method " + localAnnotatedMethod + " has no property name annotation; must have name when multiple-paramater constructor annotated as Creator"); } } }
protected boolean _handleSingleArgumentConstructor(DeserializationContext paramDeserializationContext, BeanDescription paramBeanDescription, VisibilityChecker<?> paramVisibilityChecker, AnnotationIntrospector paramAnnotationIntrospector, CreatorCollector paramCreatorCollector, AnnotatedConstructor paramAnnotatedConstructor, boolean paramBoolean1, boolean paramBoolean2, String paramString) { AnnotatedParameter localAnnotatedParameter = paramAnnotatedConstructor.getParameter(0); if (paramString == null) { PropertyName localPropertyName1; if (localAnnotatedParameter == null) localPropertyName1 = null; else localPropertyName1 = paramAnnotationIntrospector.findNameForDeserialization(localAnnotatedParameter); PropertyName localPropertyName2 = localPropertyName1; if (localPropertyName1 == null) paramString = null; else paramString = localPropertyName2.getSimpleName(); } Object localObject = paramAnnotationIntrospector.findInjectableValueId(localAnnotatedParameter); if ((localObject != null) || ((paramString != null) && (paramString.length() > 0))) { CreatorProperty[] arrayOfCreatorProperty = new CreatorProperty[1]; arrayOfCreatorProperty[0] = constructCreatorProperty(paramDeserializationContext, paramBeanDescription, paramString, 0, localAnnotatedParameter, localObject); paramCreatorCollector.addPropertyCreator(paramAnnotatedConstructor, arrayOfCreatorProperty); return true; } Class localClass = paramAnnotatedConstructor.getRawParameterType(0); if (localClass == String.class) { if ((paramBoolean1) || (paramBoolean2)) paramCreatorCollector.addStringCreator(paramAnnotatedConstructor); return true; } if ((localClass == Integer.TYPE) || (localClass == Integer.class)) { if ((paramBoolean1) || (paramBoolean2)) paramCreatorCollector.addIntCreator(paramAnnotatedConstructor); return true; } if ((localClass == Long.TYPE) || (localClass == Long.class)) { if ((paramBoolean1) || (paramBoolean2)) paramCreatorCollector.addLongCreator(paramAnnotatedConstructor); return true; } if ((localClass == Double.TYPE) || (localClass == Double.class)) { if ((paramBoolean1) || (paramBoolean2)) paramCreatorCollector.addDoubleCreator(paramAnnotatedConstructor); return true; } if (paramBoolean1) { paramCreatorCollector.addDelegatingCreator(paramAnnotatedConstructor, null); return true; } return false; }
public void configureIncompleteParameter(AnnotatedParameter paramAnnotatedParameter) { this._incompleteParameter = paramAnnotatedParameter; }
public AnnotatedParameter getIncompleteParameter() { return this._incompleteParameter; }
@Deprecated public CreatorProperty(String paramString, JavaType paramJavaType, TypeDeserializer paramTypeDeserializer, Annotations paramAnnotations, AnnotatedParameter paramAnnotatedParameter, int paramInt, Object paramObject) { this(paramString, paramJavaType, null, paramTypeDeserializer, paramAnnotations, paramAnnotatedParameter, paramInt, paramObject, true); }
public void addIncompeteParameter(AnnotatedParameter paramAnnotatedParameter) { if (this._incompleteParameter == null) this._incompleteParameter = paramAnnotatedParameter; }
public AnnotatedParameter getIncompleteParameter() { return null; }
@Deprecated public String findDeserializationName(AnnotatedParameter paramAnnotatedParameter) { return null; }
public String nameForConstructorParameter(MapperConfig<?> paramMapperConfig, AnnotatedParameter paramAnnotatedParameter, String paramString) { return paramString; }
public String nameForConstructorParameter(MapperConfig<?> paramMapperConfig, AnnotatedParameter paramAnnotatedParameter, String paramString) { return translate(paramString); }
public AnnotatedParameter getConstructorParameter() { if ((this._member instanceof AnnotatedParameter)) return (AnnotatedParameter)this._member; return null; }
public boolean hasConstructorParameter() { return this._member instanceof AnnotatedParameter; }
@Override public String nameForConstructorParameter(MapperConfig<?> config, AnnotatedParameter ctorParam, String defaultName) { return translate(defaultName); }
@Override public boolean hasConstructorParameter() { return (_member instanceof AnnotatedParameter); }
@Override public AnnotatedParameter getConstructorParameter() { return (_member instanceof AnnotatedParameter) ? (AnnotatedParameter) _member : null; }
/** * @param name Name of the logical property * @param type Type of the property, used to find deserializer * @param typeDeser Type deserializer to use for handling polymorphic type * information, if one is needed * @param contextAnnotations Contextual annotations (usually by class that * declares creator [constructor, factory method] that includes * this property) * @param param Representation of property, constructor or factory * method parameter; used for accessing annotations of the property * @param index Index of this property within creator invocatino */ public CreatorProperty(String name, JavaType type, TypeDeserializer typeDeser, Annotations contextAnnotations, AnnotatedParameter param, int index, Object injectableValueId) { super(name, type, typeDeser, contextAnnotations); _annotated = param; _creatorIndex = index; _injectableValueId = injectableValueId; }
/** * Method called to find external name (name used in JSON) for given logical * POJO property, * as defined by given constructor parameter; typically called when building a deserializer * (but not necessarily only then). * * @param config Configuration in used: either <code>SerializationConfig</code> * or <code>DeserializationConfig</code>, depending on whether method is called * during serialization or deserialization * @param ctorParam Constructor parameter used to pass property. * @param defaultName Default name that would be used for property in absence of custom strategy */ public String nameForConstructorParameter(MapperConfig<?> config, AnnotatedParameter ctorParam, String defaultName) { return defaultName; }