public Parameter[] getParameters(Executable executable) { return executable.getParameters(); } }
if (executable instanceof Constructor && ClassUtils.isInnerClass(executable.getDeclaringClass()) && executable.getParameterAnnotations().length == executable.getParameterCount() - 1) { return (index == 0 ? EMPTY_ANNOTATED_ELEMENT : executable.getParameters()[index - 1]);
/** * Return the type of the method/constructor parameter. * @return the parameter type (never {@code null}) */ public Class<?> getParameterType() { Class<?> paramType = this.parameterType; if (paramType == null) { if (this.parameterIndex < 0) { Method method = getMethod(); paramType = (method != null ? method.getReturnType() : void.class); } else { paramType = this.executable.getParameterTypes()[this.parameterIndex]; } this.parameterType = paramType; } return paramType; }
/** * Return the annotations associated with the specific method/constructor parameter. */ public Annotation[] getParameterAnnotations() { Annotation[] paramAnns = this.parameterAnnotations; if (paramAnns == null) { Annotation[][] annotationArray = this.executable.getParameterAnnotations(); int index = this.parameterIndex; if (this.executable instanceof Constructor && ClassUtils.isInnerClass(this.executable.getDeclaringClass()) && annotationArray.length == this.executable.getParameterCount() - 1) { // Bug in javac in JDK <9: annotation array excludes enclosing instance parameter // for inner classes, so access it with the actual parameter index lowered by 1 index = this.parameterIndex - 1; } paramAnns = (index >= 0 && index < annotationArray.length ? adaptAnnotationArray(annotationArray[index]) : EMPTY_ANNOTATION_ARRAY); this.parameterAnnotations = paramAnns; } return paramAnns; }
/** * Return the generic type of the method/constructor parameter. * @return the parameter type (never {@code null}) * @since 3.0 */ public Type getGenericParameterType() { Type paramType = this.genericParameterType; if (paramType == null) { if (this.parameterIndex < 0) { Method method = getMethod(); paramType = (method != null ? method.getGenericReturnType() : void.class); } else { Type[] genericParameterTypes = this.executable.getGenericParameterTypes(); int index = this.parameterIndex; if (this.executable instanceof Constructor && ClassUtils.isInnerClass(this.executable.getDeclaringClass()) && genericParameterTypes.length == this.executable.getParameterCount() - 1) { // Bug in javac: type array excludes enclosing instance parameter // for inner classes with at least one generic constructor parameter, // so access it with the actual parameter index lowered by 1 index = this.parameterIndex - 1; } paramType = (index >= 0 && index < genericParameterTypes.length ? genericParameterTypes[index] : getParameterType()); } this.genericParameterType = paramType; } return paramType; }
private static String declarerName(Parameter p) { Executable exec = p.getDeclaringExecutable(); return exec.getDeclaringClass().getName() + '.' + exec.getName(); } }
BeanDefinitionValueResolver valueResolver = new BeanDefinitionValueResolver(this.beanFactory, beanName, mbd, converter); Class<?>[] paramTypes = executable.getParameterTypes(); Object argValue = argsToResolve[argIndex]; MethodParameter methodParam = MethodParameter.forExecutable(executable, argIndex); GenericTypeResolver.resolveParameterType(methodParam, executable.getDeclaringClass()); if (argValue instanceof AutowiredArgumentMarker) { argValue = resolveAutowiredArgument(methodParam, beanName, null, converter, fallback);
/** * Takes given parameters references and returns reference set for given method or constructor. */ public BeanReferences[] resolveReferenceFromValues(final Executable methodOrCtor, final String... parameterReferences) { BeanReferences[] references = convertRefToReferences(parameterReferences); if (references == null || references.length == 0) { references = buildDefaultReferences(methodOrCtor); } if (methodOrCtor.getParameterTypes().length != references.length) { throw new PetiteException("Different number of method parameters and references for: " + methodOrCtor.getDeclaringClass().getName() + '#' + methodOrCtor.getName()); } removeAllDuplicateNames(references); return references; }
this.messageType = messageType; ReflectionUtils.ensureAccessible(this.executable); Parameter[] parameters = executable.getParameters(); this.parameterCount = executable.getParameterCount(); parameterResolvers = new ParameterResolver[parameterCount]; Class<?> supportedPayloadType = explicitPayloadType; throw new UnsupportedHandlerException( "Unable to resolve parameter " + i + " (" + parameters[i].getType().getSimpleName() + ") in handler " + executable.toGenericString() + ".", executable); throw new UnsupportedHandlerException(String.format( "The method %s seems to have parameters that put conflicting requirements on the payload type" + " applicable on that method: %s vs %s", executable.toGenericString(), supportedPayloadType, parameterResolvers[i].supportedPayloadType()), executable);
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); }
boolean hasBody = Arrays.asList(p.getDeclaringExecutable().getParameters()).stream() .filter(it -> Stream.of(it.getAnnotations()) .filter(e -> e.annotationType() == Body.class) return RouteParameter.Kind.PATH; boolean formLike = !hasBody && p.getDeclaringExecutable().getAnnotation(POST.class) != null; if (formLike) { return RouteParameter.Kind.FORM;
boolean implicitRequestObjectAnnotation, boolean isServiceMethod) { final Parameter[] parameters = constructorOrMethod.getParameters(); if (parameters.length == 0) { throw new NoParameterException(constructorOrMethod.toGenericString()); constructorOrMethod.toGenericString()); constructorOrMethod.toGenericString()); implicitRequestObjectAnnotation); } else if (!isServiceMethod && constructorOrMethod.getAnnotationsByType(RequestConverter.class).length > 0 && parameters.length == 1) { constructorOrMethod.toGenericString()); if (constructorOrMethod.isAnnotationPresent(Default.class)) { throw new IllegalArgumentException( '@' + Default.class.getSimpleName() + " is not supported for: " + constructorOrMethod.toGenericString()); .collect(Collectors.toList())); if (list.isEmpty()) { throw new NoAnnotatedParameterException(constructorOrMethod.toGenericString()); constructorOrMethod.toGenericString()); } else {
/** * Return the class that declares the underlying Method or Constructor. */ public Class<?> getDeclaringClass() { return this.executable.getDeclaringClass(); }
private static boolean isNotPrivateAndAcceptsSingleStringArgument(Executable executable) { return isNotPrivate(executable) // && (executable.getParameterCount() == 1) // && (executable.getParameterTypes()[0] == String.class); }
private BeanReferences[] updateReferencesWithDefaultsIfNeeded(final Executable methodOrCtor, BeanReferences[] references) { BeanReferences[] defaultReferences = buildDefaultReferences(methodOrCtor); if (references == null || references.length == 0) { references = defaultReferences; } if (methodOrCtor.getParameterTypes().length != references.length) { throw new PetiteException( "Different number of parameters and references for: " + methodOrCtor.getName()); } // apply default parameters for (int i = 0; i < references.length; i++) { BeanReferences parameterReferences = references[i]; if (parameterReferenceIsNotSet(parameterReferences)) { references[i] = defaultReferences[i]; } } return references; }
protected SingleMethod(Executable executable) { this.varArgs = executable.isVarArgs(); this.parameterTypes = executable.getParameterTypes(); this.genericParameterTypes = executable.getGenericParameterTypes(); }
@Override public String toString() { return getClass().getSimpleName() + " " + executable.toGenericString(); } }
executable.getGenericParameterTypes(); executable.getGenericExceptionTypes(); executable.getParameters();
hitEntity.getParameters(), paramSource, hitEntity.getMethod().getParameterTypes()); target = (T) ((Constructor<T>)hitEntity.getMethod()).newInstance(objects); }else{ if(hitEntity.getMethod().getParameterCount() > 0){ for(Type type: hitEntity.getMethod().getGenericParameterTypes()){ types.add(type.getTypeName());
ParameterNameClassVisitor(Executable executable) { super(Opcodes.ASM5); methodName = executable instanceof Constructor ? "<init>" : executable.getName(); parameterTypes = Arrays.stream(executable.getParameterTypes()) .map(Type::getType) .collect(toList()); this.methodVisitor = new ParameterNameMethodVisitor(isStatic(executable.getModifiers()), parameterTypes); }