@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. */ Linked<AnnotatedParameter> curr = _ctorParameters; do { if (curr.value.getOwner() instanceof AnnotatedConstructor) { return curr.value; } curr = curr.next; } while (curr != null); return _ctorParameters.value; }
protected PropertyName _findConstructorName(Annotated a) { if (a instanceof AnnotatedParameter) { AnnotatedParameter p = (AnnotatedParameter) a; AnnotatedWithParams ctor = p.getOwner(); if (ctor != null) { if (_java7Helper != null) { PropertyName name = _java7Helper.findConstructorName(p); if (name != null) { return name; } } } } return null; }
while (it.hasNext()) { AnnotatedParameter param = it.next(); AnnotatedWithParams owner = param.getOwner(); BeanPropertyDefinition[] defs = result.get(owner); final int index = param.getIndex();
@Override public PropertyName findConstructorName(AnnotatedParameter p) { AnnotatedWithParams ctor = p.getOwner(); if (ctor != null) { ConstructorProperties props = ctor.getAnnotation(ConstructorProperties.class); if (props != null) { String[] names = props.value(); int ix = p.getIndex(); if (ix < names.length) { return PropertyName.construct(names[ix]); } } } return null; } }
param.getOwner()); if ((creatorMode == null) || (creatorMode == JsonCreator.Mode.DISABLED)) { return;
final AnnotatedWithParams ctor = nonAnnotatedParam.getOwner(); throw new IllegalArgumentException("Argument #"+nonAnnotatedParam.getIndex() +" of constructor "+ctor+" has no property name annotation; must have name when multiple-parameter constructor annotated as Creator");
@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. */ Linked<AnnotatedParameter> curr = _ctorParameters; do { if (curr.value.getOwner() instanceof AnnotatedConstructor) { return curr.value; } curr = curr.next; } while (curr != null); return _ctorParameters.value; }
@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. */ Linked<AnnotatedParameter> curr = _ctorParameters; do { if (curr.value.getOwner() instanceof AnnotatedConstructor) { return curr.value; } curr = curr.next; } while (curr != null); return _ctorParameters.value; }
@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. */ Linked<AnnotatedParameter> curr = _ctorParameters; do { if (curr.value.getOwner() instanceof AnnotatedConstructor) { return curr.value; } curr = curr.next; } while (curr != null); return _ctorParameters.value; }
@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. */ Linked<AnnotatedParameter> curr = _ctorParameters; do { if (curr.value.getOwner() instanceof AnnotatedConstructor) { return curr.value; } curr = curr.next; } while (curr != null); return _ctorParameters.value; }
@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. */ Linked<AnnotatedParameter> curr = _ctorParameters; do { if (curr.value.getOwner() instanceof AnnotatedConstructor) { return curr.value; } curr = curr.next; } while (curr != null); return _ctorParameters.value; }
protected PropertyName _findConstructorName(Annotated a) { if (a instanceof AnnotatedParameter) { AnnotatedParameter p = (AnnotatedParameter) a; AnnotatedWithParams ctor = p.getOwner(); if (ctor != null) { if (_java7Helper != null) { PropertyName name = _java7Helper.findConstructorName(p); if (name != null) { return name; } } } } return null; }
protected PropertyName _findConstructorName(Annotated a) { if (a instanceof AnnotatedParameter) { AnnotatedParameter p = (AnnotatedParameter) a; AnnotatedWithParams ctor = p.getOwner(); if (ctor != null) { if (_java7Helper != null) { PropertyName name = _java7Helper.findConstructorName(p); if (name != null) { return name; } } } } return null; }
private String findParameterName(AnnotatedParameter annotatedParameter) { Parameter[] params; try { params = getParameters(annotatedParameter.getOwner()); } catch (MalformedParametersException e) { return null; } Parameter p = params[annotatedParameter.getIndex()]; return p.isNamePresent() ? p.getName() : null; }
protected Map<AnnotatedWithParams,BeanPropertyDefinition[]> _findCreatorsFromProperties(DeserializationContext ctxt, BeanDescription beanDesc) throws JsonMappingException { Map<AnnotatedWithParams,BeanPropertyDefinition[]> result = Collections.emptyMap(); for (BeanPropertyDefinition propDef : beanDesc.findProperties()) { Iterator<AnnotatedParameter> it = propDef.getConstructorParameters(); while (it.hasNext()) { AnnotatedParameter param = it.next(); AnnotatedWithParams owner = param.getOwner(); BeanPropertyDefinition[] defs = result.get(owner); final int index = param.getIndex(); if (defs == null) { if (result.isEmpty()) { result = new LinkedHashMap<AnnotatedWithParams,BeanPropertyDefinition[]>(); } defs = new BeanPropertyDefinition[owner.getParameterCount()]; result.put(owner, defs); } else { if (defs[index] != null) { throw new IllegalStateException("Conflict: parameter #"+index+" of "+owner +" bound to more than one property; "+defs[index]+" vs "+propDef); } } defs[index] = propDef; } } return result; }
public String findParameterName(AnnotatedParameter param) { int index = param.getIndex(); AnnotatedElement ctor = param.getOwner().getAnnotated(); String[] names = _paranamer.lookupParameterNames((AccessibleObject) ctor, false); if (names != null && index < names.length) { return names[index]; } return null; }
@Override public PropertyName findNameForDeserialization(Annotated a) { if (a instanceof AnnotatedParameter) { AnnotatedParameter ap = (AnnotatedParameter) a; if (ap.getOwner() instanceof AnnotatedConstructor) { AnnotatedConstructor ac = (AnnotatedConstructor) ap.getOwner(); Constructor<?> c = ac.getAnnotated(); ConstructorProperties properties = c.getAnnotation(ConstructorProperties.class); if (properties != null) { String[] names = properties.value(); int index = ap.getIndex(); if (index < names.length) { return new PropertyName( names[index] ); } } } } // Default return super.findNameForDeserialization(a); } }
@Override public PropertyName findConstructorName(AnnotatedParameter p) { AnnotatedWithParams ctor = p.getOwner(); if (ctor != null) { ConstructorProperties props = ctor.getAnnotation(ConstructorProperties.class); if (props != null) { String[] names = props.value(); int ix = p.getIndex(); if (ix < names.length) { return PropertyName.construct(names[ix]); } } } return null; } }
@Override public PropertyName findConstructorName(AnnotatedParameter p) { AnnotatedWithParams ctor = p.getOwner(); if (ctor != null) { ConstructorProperties props = ctor.getAnnotation(ConstructorProperties.class); if (props != null) { String[] names = props.value(); int ix = p.getIndex(); if (ix < names.length) { return PropertyName.construct(names[ix]); } } } return null; } }
PropertyDescriptor fromConstructorParameter(AnnotatedParameter ctorParam) { Executable constructor = (Executable) ctorParam.getOwner().getMember(); Parameter parameter = constructor.getParameters()[ctorParam.getIndex()]; AnnotatedType fieldType = transform(ClassUtils.getParameterTypes(constructor, type)[ctorParam.getIndex()], parameter); return new PropertyDescriptor(type, constructor.getDeclaringClass(), parameter, fieldType, ctorParam); }