本文整理了Java中java.lang.reflect.Executable.getGenericParameterTypes()
方法的一些代码示例,展示了Executable.getGenericParameterTypes()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Executable.getGenericParameterTypes()
方法的具体详情如下:
包路径:java.lang.reflect.Executable
类名称:Executable
方法名:getGenericParameterTypes
暂无
代码示例来源:origin: spring-projects/spring-framework
/**
* 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;
}
代码示例来源:origin: org.springframework/spring-core
/**
* 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;
}
代码示例来源:origin: com.github.XDean/spring-annotation
/**
* 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 {
paramType = this.executable.getGenericParameterTypes()[this.parameterIndex];
}
this.genericParameterType = paramType;
}
return paramType;
}
代码示例来源:origin: org.hibernate.validator/hibernate-validator
ParameterConstraintMappingContextImpl(ExecutableConstraintMappingContextImpl executableContext, int parameterIndex) {
super(
executableContext.getTypeContext().getConstraintMapping(),
executableContext.executable.getGenericParameterTypes()[parameterIndex]
);
this.executableContext = executableContext;
this.parameterIndex = parameterIndex;
}
代码示例来源:origin: com.oracle.truffle/truffle-api
protected SingleMethodDesc(Executable executable) {
this.varArgs = executable.isVarArgs();
this.parameterTypes = executable.getParameterTypes();
this.genericParameterTypes = executable.getGenericParameterTypes();
}
代码示例来源:origin: org.graalvm.truffle/truffle-api
protected SingleMethod(Executable executable) {
this.varArgs = executable.isVarArgs();
this.parameterTypes = executable.getParameterTypes();
this.genericParameterTypes = executable.getGenericParameterTypes();
}
代码示例来源:origin: org.hibernate.validator/hibernate-validator
/**
* Returns the type of the parameter of the given method with the given parameter index.
*
* @param executable The executable of interest.
* @param parameterIndex The index of the parameter for which the type should be returned.
*
* @return The erased type.
*/
public static Type typeOf(Executable executable, int parameterIndex) {
Type[] genericParameterTypes = executable.getGenericParameterTypes();
// getGenericParameterTypes() doesn't return synthetic parameters; in this case fall back to getParameterTypes()
if ( parameterIndex >= genericParameterTypes.length ) {
genericParameterTypes = executable.getParameterTypes();
}
Type type = genericParameterTypes[parameterIndex];
if ( type instanceof TypeVariable ) {
type = TypeHelper.getErasedType( type );
}
return type;
}
代码示例来源:origin: org.minijax/minijax-core
private Provider<?>[] getParamProviders(final Key<?> key, final Executable executable, final Set<Key<?>> chain) {
final Class<?>[] paramClasses = executable.getParameterTypes();
final Type[] paramTypes = executable.getGenericParameterTypes();
final Annotation[][] annotations = executable.getParameterAnnotations();
final Provider<?>[] result = new Provider<?>[paramTypes.length];
for (int i = 0; i < paramTypes.length; ++i) {
result[i] = getParamProvider(key, paramClasses[i], paramTypes[i], annotations[i], chain);
}
return result;
}
代码示例来源:origin: com.oracle.substratevm/library-support
executable.getGenericParameterTypes();
executable.getGenericExceptionTypes();
executable.getParameters();
代码示例来源:origin: org.apache.bval/bval-jsr
ValidateParameters(ApacheFactoryContext validatorContext, T object, E executable, Object[] parameterValues,
Class<?>[] groups, Meta<E> meta) {
super(validatorContext, groups, meta);
this.object = object;
this.parameterValues =
Validate.notNull(parameterValues, IllegalArgumentException::new, "null parameter values").clone();
final Type[] genericParameterTypes = executable.getGenericParameterTypes();
Exceptions.raiseUnless(parameterValues.length == genericParameterTypes.length, IllegalArgumentException::new,
PARAMETERS_DO_NOT_MATCH);
IntStream.range(0, genericParameterTypes.length)
.forEach(n -> Exceptions.raiseUnless(TypeUtils.isInstance(parameterValues[n], genericParameterTypes[n]),
IllegalArgumentException::new, PARAMETERS_DO_NOT_MATCH));
}
代码示例来源:origin: org.apache.tomee.patch/bval-jsr
ValidateParameters(ApacheFactoryContext validatorContext, T object, E executable, Object[] parameterValues,
Class<?>[] groups, Meta<E> meta) {
super(validatorContext, groups, meta);
this.object = object;
this.parameterValues =
Validate.notNull(parameterValues, IllegalArgumentException::new, "null parameter values").clone();
final Type[] genericParameterTypes = executable.getGenericParameterTypes();
Exceptions.raiseUnless(parameterValues.length == genericParameterTypes.length, IllegalArgumentException::new,
PARAMETERS_DO_NOT_MATCH);
IntStream.range(0, genericParameterTypes.length)
.forEach(n -> Exceptions.raiseUnless(TypeUtils.isInstance(parameterValues[n], genericParameterTypes[n]),
IllegalArgumentException::new, PARAMETERS_DO_NOT_MATCH));
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.spring-core
/**
* 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;
}
代码示例来源:origin: com.gitee.ainilili/noaoc
for(Type type: hitEntity.getMethod().getGenericParameterTypes()){
types.add(type.getTypeName());
内容来源于网络,如有侵权,请联系作者删除!