java.lang.reflect.Executable.getParameterTypes()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(9.5k)|赞(0)|评价(0)|浏览(197)

本文整理了Java中java.lang.reflect.Executable.getParameterTypes()方法的一些代码示例,展示了Executable.getParameterTypes()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Executable.getParameterTypes()方法的具体详情如下:
包路径:java.lang.reflect.Executable
类名称:Executable
方法名:getParameterTypes

Executable.getParameterTypes介绍

暂无

代码示例

代码示例来源:origin: spring-projects/spring-framework

/**
 * 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;
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * 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;
}

代码示例来源:origin: spring-projects/spring-framework

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]));
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * 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;
}

代码示例来源:origin: org.springframework/spring-core

/**
 * 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;
}

代码示例来源:origin: org.springframework/spring-web

/**
 * 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;
}

代码示例来源:origin: org.springframework/spring-webmvc

/**
 * 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;
}

代码示例来源:origin: spring-projects/spring-framework

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;
}

代码示例来源:origin: org.junit.jupiter/junit-jupiter-params

private static boolean isNotPrivateAndAcceptsSingleStringArgument(Executable executable) {
  return isNotPrivate(executable) //
      && (executable.getParameterCount() == 1) //
      && (executable.getParameterTypes()[0] == String.class);
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * 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;
}

代码示例来源:origin: org.springframework/spring-core

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;
}

代码示例来源:origin: oblac/jodd

/**
 * 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;
}

代码示例来源:origin: oblac/jodd

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;
}

代码示例来源:origin: org.springframework/spring-beans

/**
 * 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;
}

代码示例来源:origin: oblac/jodd

final Class[] paramTypes = methodOrCtor.getParameterTypes();
final BeanReferences[] references = new BeanReferences[paramTypes.length];

代码示例来源:origin: spring-projects/spring-framework

BeanDefinitionValueResolver valueResolver =
    new BeanDefinitionValueResolver(this.beanFactory, beanName, mbd, converter);
Class<?>[] paramTypes = executable.getParameterTypes();

代码示例来源:origin: org.springframework/spring-beans

BeanDefinitionValueResolver valueResolver =
    new BeanDefinitionValueResolver(this.beanFactory, beanName, mbd, converter);
Class<?>[] paramTypes = executable.getParameterTypes();

代码示例来源:origin: org.hibernate.validator/hibernate-validator

protected ExecutableConstraintMappingContextImpl(TypeConstraintMappingContextImpl<?> typeContext, Executable executable) {
  this.typeContext = typeContext;
  this.executable = executable;
  this.parameterContexts = new ParameterConstraintMappingContextImpl[executable.getParameterTypes().length];
}

代码示例来源:origin: com.oracle.truffle/truffle-api

protected SingleMethodDesc(Executable executable) {
  this.varArgs = executable.isVarArgs();
  this.parameterTypes = executable.getParameterTypes();
  this.genericParameterTypes = executable.getGenericParameterTypes();
}

代码示例来源:origin: org.hibernate.validator/hibernate-validator

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 );
}

相关文章