private static int validateIndex(Executable executable, int parameterIndex) { int count = executable.getParameterCount(); Assert.isTrue(parameterIndex >= -1 && parameterIndex < count, () -> "Parameter index needs to be between -1 and " + (count - 1)); return parameterIndex; }
int getParameterCount() { return executable.getParameterCount(); }
private static int validateIndex(Executable executable, int parameterIndex) { int count = executable.getParameterCount(); Assert.isTrue(parameterIndex >= -1 && parameterIndex < count, () -> "Parameter index needs to be between -1 and " + (count - 1)); return parameterIndex; }
/** * 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 boolean isNotPrivateAndAcceptsSingleStringArgument(Executable executable) { return isNotPrivate(executable) // && (executable.getParameterCount() == 1) // && (executable.getParameterTypes()[0] == String.class); }
/** * 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; }
Executable executable = parameter.getDeclaringExecutable(); if (executable instanceof Constructor && ClassUtils.isInnerClass(executable.getDeclaringClass()) && executable.getParameterAnnotations().length == executable.getParameterCount() - 1) {
/** * 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; }
ReflectionUtils.ensureAccessible(this.executable); Parameter[] parameters = executable.getParameters(); this.parameterCount = executable.getParameterCount(); parameterResolvers = new ParameterResolver[parameterCount]; Class<?> supportedPayloadType = explicitPayloadType;
&& executable.getParameterAnnotations().length == executable.getParameterCount() - 1) {
private List<String> getParameterNamesEx(Executable methodOrConstructor) { int parameterCount = methodOrConstructor.getParameterCount(); List<String> parameterNames = new ArrayList<>(parameterCount); for (int i = 0; i < parameterCount; i++) { parameterNames.add(ParamUtils.getParameterName(methodOrConstructor, i)); } return Collections.unmodifiableList(parameterNames); } }
private static int validateIndex(Executable executable, int parameterIndex) { int count = executable.getParameterCount(); Assert.isTrue(parameterIndex >= -1 && parameterIndex < count, () -> "Parameter index needs to be between -1 and " + (count - 1)); return parameterIndex; }
private static int validateIndex(Executable executable, int parameterIndex) { int count = executable.getParameterCount(); Assert.isTrue(parameterIndex < count, () -> "Parameter index needs to be between -1 and " + (count - 1)); return parameterIndex; }
/** * Return MethodParameters for each parameter of the given method/constructor. */ public static Stream<MethodParameter> createMethodParameters(Executable executable) { return IntStream.range(0, executable.getParameterCount()) .mapToObj(i -> createMethodParameter(executable, i)); }
private List<String> getParameterNamesEx(Executable methodOrConstructor) { int parameterCount = methodOrConstructor.getParameterCount(); List<String> parameterNames = new ArrayList<>(parameterCount); for (int i = 0; i < parameterCount; i++) { parameterNames.add(ParamUtils.getParameterName(methodOrConstructor, i)); } return Collections.unmodifiableList(parameterNames); } }
private ConstraintTarget impliedConstraintTarget() { if (meta.getHost().getParameterCount() == 0) { return ConstraintTarget.RETURN_VALUE; } if (Void.TYPE.equals(meta.getType())) { return ConstraintTarget.PARAMETERS; } return null; } }
public List<String> getParameterNames(Executable executable) { //skip parameterless methods if ( executable.getParameterCount() == 0 ) { return Collections.emptyList(); } if ( executable instanceof Method ) { return delegate.getParameterNames( (Method) executable ); } else { return delegate.getParameterNames( (Constructor<?>) executable ); } }
ParameterD(Meta.ForParameter meta, int index, MetadataReader.ForContainer<Parameter> reader, P parent) { super(reader, parent); Validate.isTrue(index >= 0 && index < meta.getHost().getDeclaringExecutable().getParameterCount(), "Invalid parameter index %d", index); this.index = index; name = reader.meta.getName(); type = resolveType(); }
ParameterD(Meta.ForParameter meta, int index, MetadataReader.ForContainer<Parameter> reader, P parent) { super(reader, parent); Validate.isTrue(index >= 0 && index < meta.getHost().getDeclaringExecutable().getParameterCount(), "Invalid parameter index %d", index); this.index = index; name = reader.meta.getName(); type = resolveType(); }