本文整理汇总了Java中java.lang.reflect.TypeVariable.getName方法的典型用法代码示例。如果您正苦于以下问题:Java TypeVariable.getName方法的具体用法?Java TypeVariable.getName怎么用?Java TypeVariable.getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.lang.reflect.TypeVariable
的用法示例。
在下文中一共展示了TypeVariable.getName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: equals
import java.lang.reflect.TypeVariable; //导入方法依赖的package包/类
@Override
public boolean equals(Object o) {
if (o instanceof TypeVariable) {
TypeVariable that = (TypeVariable) o;
GenericDeclaration thatDecl = that.getGenericDeclaration();
String thatName = that.getName();
return
(genericDeclaration == null ?
thatDecl == null :
genericDeclaration.equals(thatDecl)) &&
(name == null ?
thatName == null :
name.equals(thatName));
} else
return false;
}
示例2: createByParamName
import java.lang.reflect.TypeVariable; //导入方法依赖的package包/类
private static JavaType createByParamName(final ImplementClass implementClass, final TypeVariable<?> variable) {
GenericDeclaration declaration = variable.getGenericDeclaration();
String name = variable.getName();
TypeVariable<?>[] typeParameters = declaration.getTypeParameters();
for (int index = 0; index < typeParameters.length; index++) {
TypeVariable<?> type = typeParameters[index];
if (name.equals(type.getName())) {
if (declaration instanceof Class) {
Class<?> declarationClass = (Class<?>) declaration;
Class<?> sub = implementClass.getSubclass(declarationClass);
if (sub != null) {
Type genericSuperclass = implementClass.getGenericParentClass(declarationClass);
if (genericSuperclass instanceof ParameterizedType) {
ParameterizedType parameterizedType = (ParameterizedType) genericSuperclass;
return create(implementClass, parameterizedType.getActualTypeArguments()[index]);
}
// Generics未指定
}
return new VariableJavaType(implementClass, type);
} else if (declaration instanceof Executable) {
return new VariableJavaType(implementClass, type);
}
}
}
throw new IllegalArgumentException();
}
示例3: getTrueType
import java.lang.reflect.TypeVariable; //导入方法依赖的package包/类
private static Type getTrueType(
Type type,
TypeVariable<?>[] typeVariables,
Type[] actualTypes) {
if (type instanceof TypeVariable<?>) {
TypeVariable<?> tv = (TypeVariable<?>) type;
String name = tv.getName();
if (actualTypes != null) {
for (int i = 0; i < typeVariables.length; i++) {
if (name.equals(typeVariables[i].getName())) {
return actualTypes[i];
}
}
}
return tv;
// }else if (type instanceof Class<?>) {
// return type;
} else if (type instanceof GenericArrayType) {
Type ct = ((GenericArrayType) type).getGenericComponentType();
if (ct instanceof Class<?>) {
return Array.newInstance((Class<?>) ct, 0).getClass();
}
}
return type;
}
示例4: equals
import java.lang.reflect.TypeVariable; //导入方法依赖的package包/类
@Override
public boolean equals(Object o) {
if (o instanceof TypeVariable &&
o.getClass() == TypeVariableImpl.class) {
TypeVariable<?> that = (TypeVariable<?>) o;
GenericDeclaration thatDecl = that.getGenericDeclaration();
String thatName = that.getName();
return Objects.equals(genericDeclaration, thatDecl) &&
Objects.equals(name, thatName);
} else
return false;
}
示例5: VariableJavaType
import java.lang.reflect.TypeVariable; //导入方法依赖的package包/类
VariableJavaType(final ImplementClass implementClass, final TypeVariable<?> typeVariable) {
this.implementClass = implementClass;
this.variableName = typeVariable.getName();
this.bounds = typeVariable.getBounds();
this.javaTypeBounds = new JavaType[this.bounds.length];
this.general = getJavaType(0);
}
示例6: TypeParameterSignature
import java.lang.reflect.TypeVariable; //导入方法依赖的package包/类
TypeParameterSignature(TypeVariable<?> typeParameter) {
name = typeParameter.getName();
bounds = Arrays.asList(typeParameter.getBounds());
}