/** * 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; }
/** * Whether to raise a fatal bind exception on validation errors. * @param parameter the method parameter declaration * @return {@code true} if the next method parameter is not of type {@link Errors} * @since 5.0 */ protected boolean isBindExceptionRequired(MethodParameter parameter) { int i = parameter.getParameterIndex(); Class<?>[] paramTypes = parameter.getExecutable().getParameterTypes(); boolean hasBindingResult = (paramTypes.length > (i + 1) && Errors.class.isAssignableFrom(paramTypes[i + 1])); return !hasBindingResult; }
private boolean hasErrorsArgument(MethodParameter parameter) { int i = parameter.getParameterIndex(); Class<?>[] paramTypes = parameter.getExecutable().getParameterTypes(); return (paramTypes.length > i + 1 && Errors.class.isAssignableFrom(paramTypes[i + 1])); }
/** * Whether to raise a fatal bind exception on validation errors. * @param binder the data binder used to perform data binding * @param parameter the method parameter descriptor * @return {@code true} if the next method argument is not of type {@link Errors} * @since 4.1.5 */ protected boolean isBindExceptionRequired(WebDataBinder binder, MethodParameter parameter) { int i = parameter.getParameterIndex(); Class<?>[] paramTypes = parameter.getExecutable().getParameterTypes(); boolean hasBindingResult = (paramTypes.length > (i + 1) && Errors.class.isAssignableFrom(paramTypes[i + 1])); return !hasBindingResult; }
/** * 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; }
/** * Whether to raise a fatal bind exception on validation errors. * @param parameter the method parameter declaration * @return {@code true} if the next method parameter is not of type {@link Errors} * @since 5.0 */ protected boolean isBindExceptionRequired(MethodParameter parameter) { int i = parameter.getParameterIndex(); Class<?>[] paramTypes = parameter.getExecutable().getParameterTypes(); boolean hasBindingResult = (paramTypes.length > (i + 1) && Errors.class.isAssignableFrom(paramTypes[i + 1])); return !hasBindingResult; }
/** * Whether to raise a fatal bind exception on validation errors. * @param binder the data binder used to perform data binding * @param parameter the method parameter descriptor * @return {@code true} if the next method argument is not of type {@link Errors} * @since 4.1.5 */ protected boolean isBindExceptionRequired(WebDataBinder binder, MethodParameter parameter) { int i = parameter.getParameterIndex(); Class<?>[] paramTypes = parameter.getExecutable().getParameterTypes(); boolean hasBindingResult = (paramTypes.length > (i + 1) && Errors.class.isAssignableFrom(paramTypes[i + 1])); return !hasBindingResult; }
public MethodParameterTypeProvider(MethodParameter methodParameter) { this.methodName = (methodParameter.getMethod() != null ? methodParameter.getMethod().getName() : null); this.parameterTypes = methodParameter.getExecutable().getParameterTypes(); this.declaringClass = methodParameter.getDeclaringClass(); this.parameterIndex = methodParameter.getParameterIndex(); this.methodParameter = methodParameter; }
private static boolean isNotPrivateAndAcceptsSingleStringArgument(Executable executable) { return isNotPrivate(executable) // && (executable.getParameterCount() == 1) // && (executable.getParameterTypes()[0] == String.class); }
/** * Create a new descriptor for a method or constructor parameter. * @param methodParameter the MethodParameter to wrap * @param required whether the dependency is required * @param eager whether this dependency is 'eager' in the sense of * eagerly resolving potential target beans for type matching */ public DependencyDescriptor(MethodParameter methodParameter, boolean required, boolean eager) { super(methodParameter); this.declaringClass = methodParameter.getDeclaringClass(); if (methodParameter.getMethod() != null) { this.methodName = methodParameter.getMethod().getName(); } this.parameterTypes = methodParameter.getExecutable().getParameterTypes(); this.parameterIndex = methodParameter.getParameterIndex(); this.containingClass = methodParameter.getContainingClass(); this.required = required; this.eager = eager; }
public MethodParameterTypeProvider(MethodParameter methodParameter) { this.methodName = (methodParameter.getMethod() != null ? methodParameter.getMethod().getName() : null); this.parameterTypes = methodParameter.getExecutable().getParameterTypes(); this.declaringClass = methodParameter.getDeclaringClass(); this.parameterIndex = methodParameter.getParameterIndex(); this.methodParameter = methodParameter; }
/** * 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; }
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; }
/** * Create a new descriptor for a method or constructor parameter. * @param methodParameter the MethodParameter to wrap * @param required whether the dependency is required * @param eager whether this dependency is 'eager' in the sense of * eagerly resolving potential target beans for type matching */ public DependencyDescriptor(MethodParameter methodParameter, boolean required, boolean eager) { super(methodParameter); this.declaringClass = methodParameter.getDeclaringClass(); if (methodParameter.getMethod() != null) { this.methodName = methodParameter.getMethod().getName(); } this.parameterTypes = methodParameter.getExecutable().getParameterTypes(); this.parameterIndex = methodParameter.getParameterIndex(); this.containingClass = methodParameter.getContainingClass(); this.required = required; this.eager = eager; }
final Class[] paramTypes = methodOrCtor.getParameterTypes(); final BeanReferences[] references = new BeanReferences[paramTypes.length];
BeanDefinitionValueResolver valueResolver = new BeanDefinitionValueResolver(this.beanFactory, beanName, mbd, converter); Class<?>[] paramTypes = executable.getParameterTypes();
BeanDefinitionValueResolver valueResolver = new BeanDefinitionValueResolver(this.beanFactory, beanName, mbd, converter); Class<?>[] paramTypes = executable.getParameterTypes();
protected ExecutableConstraintMappingContextImpl(TypeConstraintMappingContextImpl<?> typeContext, Executable executable) { this.typeContext = typeContext; this.executable = executable; this.parameterContexts = new ParameterConstraintMappingContextImpl[executable.getParameterTypes().length]; }
protected SingleMethodDesc(Executable executable) { this.varArgs = executable.isVarArgs(); this.parameterTypes = executable.getParameterTypes(); this.genericParameterTypes = executable.getGenericParameterTypes(); }
public ExecutableFormatter(Executable executable) { String name = ExecutableHelper.getSimpleName( executable ); if ( executable instanceof Method ) { name = executable.getDeclaringClass().getSimpleName() + "#" + name; } Class<?>[] parameterTypes = executable.getParameterTypes(); this.stringRepresentation = ExecutableHelper.getExecutableAsString( name, parameterTypes ); }