本文整理了Java中java.lang.reflect.Constructor.getGenericParameterTypes()
方法的一些代码示例,展示了Constructor.getGenericParameterTypes()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Constructor.getGenericParameterTypes()
方法的具体详情如下:
包路径:java.lang.reflect.Constructor
类名称:Constructor
方法名:getGenericParameterTypes
[英]Returns the generic parameter types as an array of Typeinstances, in declaration order. If this constructor has no generic parameters, an empty array is returned.
[中]以Typeinstances数组的形式按声明顺序返回泛型参数类型。如果此构造函数没有泛型参数,则返回空数组。
代码示例来源:origin: org.codehaus.jackson/jackson-mapper-asl
@Override
public Type getParameterType(int index)
{
Type[] types = _constructor.getGenericParameterTypes();
return (index >= types.length) ? null : types[index];
}
代码示例来源:origin: prestodb/presto
@Override
@Deprecated // since 2.7
public Type getGenericParameterType(int index) {
Type[] types = _constructor.getGenericParameterTypes();
if (index >= types.length) {
return null;
}
return types[index];
}
代码示例来源:origin: redisson/redisson
@Override
@Deprecated // since 2.7
public Type getGenericParameterType(int index) {
Type[] types = _constructor.getGenericParameterTypes();
if (index >= types.length) {
return null;
}
return types[index];
}
代码示例来源:origin: spring-projects/spring-loaded
public static Type[] callGetGenericParameterTypes(Constructor thiz) {
return thiz.getGenericParameterTypes();
}
代码示例来源:origin: apache/flink
public LambdaExecutable(Constructor<?> constructor) {
this.parameterTypes = constructor.getGenericParameterTypes();
this.returnType = constructor.getDeclaringClass();
this.name = constructor.getName();
this.executable = constructor;
}
代码示例来源:origin: apache/drill
@Override
@Deprecated // since 2.7
public Type getGenericParameterType(int index) {
Type[] types = _constructor.getGenericParameterTypes();
if (index >= types.length) {
return null;
}
return types[index];
}
代码示例来源:origin: google/guava
@Override
Type[] getGenericParameterTypes() {
Type[] types = constructor.getGenericParameterTypes();
if (types.length > 0 && mayNeedHiddenThis()) {
Class<?>[] rawParamTypes = constructor.getParameterTypes();
if (types.length == rawParamTypes.length
&& rawParamTypes[0] == getDeclaringClass().getEnclosingClass()) {
// first parameter is the hidden 'this'
return Arrays.copyOfRange(types, 1, types.length);
}
}
return types;
}
代码示例来源:origin: prestodb/presto
@Override
public JavaType getParameterType(int index) {
Type[] types = _constructor.getGenericParameterTypes();
if (index >= types.length) {
return null;
}
return _typeContext.resolveType(types[index]);
}
代码示例来源:origin: redisson/redisson
@Override
public JavaType getParameterType(int index) {
Type[] types = _constructor.getGenericParameterTypes();
if (index >= types.length) {
return null;
}
return _typeContext.resolveType(types[index]);
}
代码示例来源:origin: lettuce-io/lettuce-core
/**
* Return the generic type of the method/constructor parameter.
*
* @return the parameter type (never {@code null})
*/
public Type getGenericParameterType() {
if (this.genericParameterType == null) {
if (this.parameterIndex < 0) {
this.genericParameterType = (this.method != null ? this.method.getGenericReturnType() : null);
} else {
this.genericParameterType = (this.method != null ? this.method.getGenericParameterTypes()[this.parameterIndex]
: this.constructor.getGenericParameterTypes()[this.parameterIndex]);
}
}
return this.genericParameterType;
}
代码示例来源:origin: prestodb/presto
@Override
Type[] getGenericParameterTypes() {
Type[] types = constructor.getGenericParameterTypes();
if (types.length > 0 && mayNeedHiddenThis()) {
Class<?>[] rawParamTypes = constructor.getParameterTypes();
if (types.length == rawParamTypes.length
&& rawParamTypes[0] == getDeclaringClass().getEnclosingClass()) {
// first parameter is the hidden 'this'
return Arrays.copyOfRange(types, 1, types.length);
}
}
return types;
}
代码示例来源:origin: wildfly/wildfly
@Override
public Object dispatch() throws Throwable {
return ctor.newInstance(toObjects(ctor.getGenericParameterTypes()));
}
}
代码示例来源:origin: bootique/bootique
private static Type propertyTypeFromConstructor(Constructor maybeConstructor) {
Type[] paramTypes = maybeConstructor.getGenericParameterTypes();
if (paramTypes.length != 1) {
throw new IllegalStateException("Constructor '" + maybeConstructor.toString()
+ "' is annotated with @BQConfigProperty, but does not match expected signature."
+ " It must take exactly one parameter");
}
return paramTypes[0];
}
代码示例来源:origin: apache/drill
@Override
public JavaType getParameterType(int index) {
Type[] types = _constructor.getGenericParameterTypes();
if (index >= types.length) {
return null;
}
return _typeContext.resolveType(types[index]);
}
代码示例来源:origin: google/j2objc
@Override
Type[] getGenericParameterTypes() {
Type[] types = constructor.getGenericParameterTypes();
if (types.length > 0 && mayNeedHiddenThis()) {
Class<?>[] rawParamTypes = constructor.getParameterTypes();
if (types.length == rawParamTypes.length
&& rawParamTypes[0] == getDeclaringClass().getEnclosingClass()) {
// first parameter is the hidden 'this'
return Arrays.copyOfRange(types, 1, types.length);
}
}
return types;
}
代码示例来源:origin: lettuce-io/lettuce-core
public List<TypeInformation<?>> getParameterTypes(Constructor<?> constructor) {
LettuceAssert.notNull(constructor, "Constructor must not be null!");
Type[] types = constructor.getGenericParameterTypes();
List<TypeInformation<?>> result = new ArrayList<TypeInformation<?>>(types.length);
for (Type parameterType : types) {
result.add(createInfo(parameterType));
}
return result;
}
代码示例来源:origin: wildfly/wildfly
@Override
Type[] getGenericParameterTypes() {
Type[] types = constructor.getGenericParameterTypes();
if (types.length > 0 && mayNeedHiddenThis()) {
Class<?>[] rawParamTypes = constructor.getParameterTypes();
if (types.length == rawParamTypes.length
&& rawParamTypes[0] == getDeclaringClass().getEnclosingClass()) {
// first parameter is the hidden 'this'
return Arrays.copyOfRange(types, 1, types.length);
}
}
return types;
}
代码示例来源:origin: redisson/redisson
@Override
@CachedReturnPlugin.Enhance("delegate")
protected Generic resolve() {
java.lang.reflect.Type[] type = constructor.getGenericParameterTypes();
return erasure.length == type.length
? Sort.describe(type[index], getAnnotationReader())
: OfNonGenericType.ForLoadedType.of(erasure[index]);
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void forConstructorParameter() throws Exception {
Constructor<Constructors> constructor = Constructors.class.getConstructor(List.class);
ResolvableType type = ResolvableType.forConstructorParameter(constructor, 0);
assertThat(type.getType(), equalTo(constructor.getGenericParameterTypes()[0]));
}
代码示例来源:origin: querydsl/querydsl
private void addConstructors(Class<?> cl, EntityType type) {
for (Constructor<?> constructor : cl.getConstructors()) {
if (constructor.isAnnotationPresent(QueryProjection.class)) {
List<Parameter> parameters = Lists.newArrayList();
for (int i = 0; i < constructor.getParameterTypes().length; i++) {
Type parameterType = typeFactory.get(
constructor.getParameterTypes()[i],
constructor.getGenericParameterTypes()[i]);
for (Annotation annotation : constructor.getParameterAnnotations()[i]) {
if (annotation.annotationType().equals(QueryType.class)) {
QueryType queryType = (QueryType) annotation;
parameterType = parameterType.as(TypeCategory.valueOf(queryType.value().name()));
}
}
parameters.add(new Parameter("param" + i, parameterType));
}
type.addConstructor(new com.mysema.codegen.model.Constructor(parameters));
}
}
}
内容来源于网络,如有侵权,请联系作者删除!