@Override public <A extends Annotation> A getAnnotation(Class<A> acls) { if (_annotated == null) { return null; } return _annotated.getAnnotation(acls); }
public final AnnotatedParameter getParameter(int index) { return new AnnotatedParameter(this, getParameterType(index), _paramAnnotations[index], index); }
@Override public void setValue(Object pojo, Object value) throws UnsupportedOperationException { throw new UnsupportedOperationException("Cannot call setValue() on constructor parameter of " +getDeclaringClass().getName()); }
throws JsonMappingException JavaType t0 = config.getTypeFactory().constructType(param.getParameterType(), beanDesc.bindingsForBeanType()); BeanProperty.Std property = new BeanProperty.Std(name, t0, beanDesc.getClassAnnotations(), param); JavaType type = resolveType(config, beanDesc, t0, param, property);
@Override public String toString() { return "[parameter #"+getIndex()+", annotations: "+_annotations+"]"; } }
@SuppressWarnings("unchecked") public void mergeAnnotations(boolean forSerialization) { if (forSerialization) { if (_getters != null) { AnnotationMap ann = _mergeAnnotations(0, _getters, _fields, _ctorParameters, _setters); _getters = _getters.withValue(_getters.value.withAnnotations(ann)); } else if (_fields != null) { AnnotationMap ann = _mergeAnnotations(0, _fields, _ctorParameters, _setters); _fields = _fields.withValue(_fields.value.withAnnotations(ann)); } } else { if (_ctorParameters != null) { AnnotationMap ann = _mergeAnnotations(0, _ctorParameters, _setters, _fields, _getters); _ctorParameters = _ctorParameters.withValue(_ctorParameters.value.withAnnotations(ann)); } else if (_setters != null) { AnnotationMap ann = _mergeAnnotations(0, _setters, _fields, _getters); _setters = _setters.withValue(_setters.value.withAnnotations(ann)); } else if (_fields != null) { AnnotationMap ann = _mergeAnnotations(0, _fields, _getters); _fields = _fields.withValue(_fields.value.withAnnotations(ann)); } } }
@Override public AnnotatedParameter getConstructorParameter() { if (_ctorParameters == null) { return null; } /* Hmmh. Checking for constructor parameters is trickier; for one, * we must allow creator and factory method annotations. * If this is the case, constructor parameter has the precedence. * * So, for now, just try finding the first constructor parameter; * if none, first factory method. And don't check for dups, if we must, * can start checking for them later on. */ Node<AnnotatedParameter> curr = _ctorParameters; do { if (curr.value.getOwner() instanceof AnnotatedConstructor) { return curr.value; } curr = curr.next; } while (curr != null); return _ctorParameters.value; }
throws JsonMappingException JavaType t0 = config.getTypeFactory().constructType(param.getParameterType(), beanDesc.bindingsForBeanType()); BeanProperty.Std property = new BeanProperty.Std(name, t0, beanDesc.getClassAnnotations(), param); JavaType type = resolveType(config, beanDesc, t0, param, property);
+ctor); } else { // otherwise, epic fail throw new IllegalArgumentException("Argument #"+nonAnnotatedParam.getIndex()+" of constructor "+ctor+" has no property name annotation; must have name when multiple-paramater constructor annotated as Creator");
@SuppressWarnings("unchecked") public void mergeAnnotations(boolean forSerialization) { if (forSerialization) { if (_getters != null) { AnnotationMap ann = _mergeAnnotations(0, _getters, _fields, _ctorParameters, _setters); _getters = _getters.withValue(_getters.value.withAnnotations(ann)); } else if (_fields != null) { AnnotationMap ann = _mergeAnnotations(0, _fields, _ctorParameters, _setters); _fields = _fields.withValue(_fields.value.withAnnotations(ann)); } } else { if (_ctorParameters != null) { AnnotationMap ann = _mergeAnnotations(0, _ctorParameters, _setters, _fields, _getters); _ctorParameters = _ctorParameters.withValue(_ctorParameters.value.withAnnotations(ann)); } else if (_setters != null) { AnnotationMap ann = _mergeAnnotations(0, _setters, _fields, _getters); _setters = _setters.withValue(_setters.value.withAnnotations(ann)); } else if (_fields != null) { AnnotationMap ann = _mergeAnnotations(0, _fields, _getters); _fields = _fields.withValue(_fields.value.withAnnotations(ann)); } } }
@Override public AnnotatedParameter getConstructorParameter() { if (_ctorParameters == null) { return null; } /* Hmmh. Checking for constructor parameters is trickier; for one, * we must allow creator and factory method annotations. * If this is the case, constructor parameter has the precedence. * * So, for now, just try finding the first constructor parameter; * if none, first factory method. And don't check for dups, if we must, * can start checking for them later on. */ Node<AnnotatedParameter> curr = _ctorParameters; do { if (curr.value.getOwner() instanceof AnnotatedConstructor) { return curr.value; } curr = curr.next; } while (curr != null); return _ctorParameters.value; }
@Override public String findPropertyNameForParam(AnnotatedParameter param) { if (param != null) { JsonProperty pann = param.getAnnotation(JsonProperty.class); if (pann != null) { return pann.value(); } /* And can not use JsonDeserialize as we can not use * name auto-detection (names of local variables including * parameters are not necessarily preserved in bytecode) */ } return null; }
public final AnnotatedParameter getParameter(int index) { return new AnnotatedParameter(this, getParameterType(index), _paramAnnotations[index], index); }
@Override public void setValue(Object pojo, Object value) throws UnsupportedOperationException { throw new UnsupportedOperationException("Cannot call setValue() on constructor parameter of " +getDeclaringClass().getName()); }
/** * Method that will construct a property object that represents * a logical property passed via Creator (constructor or static * factory method) */ protected SettableBeanProperty constructCreatorProperty(DeserializationConfig config, BasicBeanDescription beanDesc, String name, int index, AnnotatedParameter param) throws JsonMappingException { JavaType type = resolveType(config, beanDesc, param.getParameterType(), param); // Is there an annotation that specifies exact deserializer? JsonDeserializer<Object> deser = findDeserializerFromAnnotation(config, param); // If yes, we are mostly done: if (deser != null) { SettableBeanProperty.CreatorProperty prop = new SettableBeanProperty.CreatorProperty(name, type, beanDesc.getBeanClass(), index); prop.setValueDeserializer(deser); return prop; } // Otherwise may have other type specifying annotations type = modifyTypeByAnnotation(config, param, type); return new SettableBeanProperty.CreatorProperty(name, type, beanDesc.getBeanClass(), index); } }
@Override public String toString() { return "[parameter #"+getIndex()+", annotations: "+_annotations+"]"; } }
@SuppressWarnings("unchecked") public void mergeAnnotations(boolean forSerialization) { if (forSerialization) { if (_getters != null) { AnnotationMap ann = _mergeAnnotations(0, _getters, _fields, _ctorParameters, _setters); _getters = _getters.withValue(_getters.value.withAnnotations(ann)); } else if (_fields != null) { AnnotationMap ann = _mergeAnnotations(0, _fields, _ctorParameters, _setters); _fields = _fields.withValue(_fields.value.withAnnotations(ann)); } } else { if (_ctorParameters != null) { AnnotationMap ann = _mergeAnnotations(0, _ctorParameters, _setters, _fields, _getters); _ctorParameters = _ctorParameters.withValue(_ctorParameters.value.withAnnotations(ann)); } else if (_setters != null) { AnnotationMap ann = _mergeAnnotations(0, _setters, _fields, _getters); _setters = _setters.withValue(_setters.value.withAnnotations(ann)); } else if (_fields != null) { AnnotationMap ann = _mergeAnnotations(0, _fields, _getters); _fields = _fields.withValue(_fields.value.withAnnotations(ann)); } } }
@Override public AnnotatedParameter getConstructorParameter() { if (_ctorParameters == null) { return null; } /* Hmmh. Checking for constructor parameters is trickier; for one, * we must allow creator and factory method annotations. * If this is the case, constructor parameter has the precedence. * * So, for now, just try finding the first constructor parameter; * if none, first factory method. And don't check for dups, if we must, * can start checking for them later on. */ Node<AnnotatedParameter> curr = _ctorParameters; do { if (curr.value.getOwner() instanceof AnnotatedConstructor) { return curr.value; } curr = curr.next; } while (curr != null); return _ctorParameters.value; }
@Override public <A extends Annotation> A getAnnotation(Class<A> acls) { if (_annotated == null) { return null; } return _annotated.getAnnotation(acls); }
@Override public AnnotatedParameter getParameter(int index) { return new AnnotatedParameter(this, getParameterType(index), _paramAnnotations[index]); }