本文整理匯總了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());
}