? getConstructors() : getFactoryMethods(); for (AnnotatedWithParams creator : l) { int argCount = creator.getParameterCount(); if (argCount < 1) continue; String name = _annotationIntrospector.findPropertyNameForParam(creator.getParameter(0)); if (name == null) continue; if (names == null) { names.add(_annotationIntrospector.findPropertyNameForParam(creator.getParameter(p)));
protected JavaType getType(TypeBindings bindings, TypeVariable<?>[] typeParams) { // [JACKSON-468] Need to consider local type binding declarations too... if (typeParams != null && typeParams.length > 0) { bindings = bindings.childInstance(); for (TypeVariable<?> var : typeParams) { String name = var.getName(); // to prevent infinite loops, need to first add placeholder ("<T extends Enum<T>>" etc) bindings._addPlaceholder(name); // About only useful piece of information is the lower bound (which is at least Object.class) Type lowerBound = var.getBounds()[0]; JavaType type = (lowerBound == null) ? TypeFactory.unknownType() : bindings.resolveType(lowerBound); bindings.addBinding(var.getName(), type); } } return bindings.resolveType(getGenericType()); }
/** * Method called to fully resolve type of one of parameters, given * specified type variable bindings. * * @since 1.8 */ public final JavaType resolveParameterType(int index, TypeBindings bindings) { return bindings.resolveType(getParameterType(index)); }
@Override public Object createFromInt(int value) throws IOException, JsonProcessingException { try { // First: "native" int methods work best: if (_fromIntCreator != null) { return _fromIntCreator.call1(Integer.valueOf(value)); } // but if not, can do widening conversion if (_fromLongCreator != null) { return _fromLongCreator.call1(Long.valueOf(value)); } } catch (Exception e) { throw wrapException(e); } throw new JsonMappingException("Can not instantiate value of type "+getValueTypeDesc() +" from JSON integral number; no single-int-arg constructor/factory method"); }
/** * Method called by parameter object when an augmented instance is created; * needs to replace parameter with new instance * * @since 1.9 */ protected AnnotatedParameter replaceParameterAnnotations(int index, AnnotationMap ann) { _paramAnnotations[index] = ann; return getParameter(index); }
@Override public Object createFromObjectWith(Object[] args) throws IOException, JsonProcessingException { if (_withArgsCreator == null) { // sanity-check; caller should check throw new IllegalStateException("No with-args constructor for "+getValueTypeDesc()); } try { return _withArgsCreator.call(args); } catch (ExceptionInInitializerError e) { throw wrapException(e); } catch (Exception e) { throw wrapException(e); } }
/** * Returns modifiers of the constructor, as parameters do not * have independent modifiers. */ @Override public int getModifiers() { return _owner.getModifiers(); }
@Override public Member getMember() { /* This is bit tricky: since there is no JDK equivalent; can either * return null or owner... let's do latter, for now. */ return _owner.getMember(); }
@Override public Class<?> getDeclaringClass() { return _owner.getDeclaringClass(); }
protected AnnotatedWithParams verifyNonDup(AnnotatedWithParams newOne, AnnotatedWithParams oldOne, String type) { if (oldOne != null) { // important: ok to override factory with constructor; but not within same type, so: if (oldOne.getClass() == newOne.getClass()) { throw new IllegalArgumentException("Conflicting "+type+" creators: already had "+oldOne+", encountered "+newOne); } } if (_canFixAccess) { ClassUtil.checkAndFixAccess((Member) newOne.getAnnotated()); } return newOne; } }
@Override public Object createFromString(String value) throws IOException, JsonProcessingException { if (_fromStringCreator != null) { try { return _fromStringCreator.call1(value); } catch (Exception e) { throw wrapException(e); } } return _createFromStringFallbacks(value); }
/** * Method called by parameter object when an augmented instance is created; * needs to replace parameter with new instance * * @since 1.9 */ protected AnnotatedParameter replaceParameterAnnotations(int index, AnnotationMap ann) { _paramAnnotations[index] = ann; return getParameter(index); }
@Override public Object createUsingDefault() throws IOException, JsonProcessingException { if (_defaultCreator == null) { // sanity-check; caller should check throw new IllegalStateException("No default constructor for "+getValueTypeDesc()); } try { return _defaultCreator.call(); } catch (ExceptionInInitializerError e) { throw wrapException(e); } catch (Exception e) { throw wrapException(e); } }
/** * Returns modifiers of the constructor, as parameters do not * have independent modifiers. */ @Override public int getModifiers() { return _owner.getModifiers(); }
@Override public Member getMember() { /* This is bit tricky: since there is no JDK equivalent; can either * return null or owner... let's do latter, for now. */ return _owner.getMember(); }
@Override public Class<?> getDeclaringClass() { return _owner.getDeclaringClass(); }
protected AnnotatedWithParams verifyNonDup(AnnotatedWithParams newOne, AnnotatedWithParams oldOne, String type) { if (oldOne != null) { // important: ok to override factory with constructor; but not within same type, so: if (oldOne.getClass() == newOne.getClass()) { throw new IllegalArgumentException("Conflicting "+type+" creators: already had "+oldOne+", encountered "+newOne); } } if (_canFixAccess) { ClassUtil.checkAndFixAccess((Member) newOne.getAnnotated()); } return newOne; } }
? getConstructors() : getFactoryMethods(); for (AnnotatedWithParams creator : l) { int argCount = creator.getParameterCount(); if (argCount < 1) continue; String name = _annotationIntrospector.findPropertyNameForParam(creator.getParameter(0)); if (name == null) continue; if (names == null) { names.add(_annotationIntrospector.findPropertyNameForParam(creator.getParameter(p)));
@Override public Object createFromLong(long value) throws IOException, JsonProcessingException { try { if (_fromLongCreator != null) { return _fromLongCreator.call1(Long.valueOf(value)); } } catch (Exception e) { throw wrapException(e); } throw new JsonMappingException("Can not instantiate value of type "+getValueTypeDesc() +" from JSON long integral number; no single-long-arg constructor/factory method"); }
public final AnnotatedParameter getParameter(int index) { return new AnnotatedParameter(this, getParameterType(index), _paramAnnotations[index], index); }