本文整理匯總了Java中java.lang.reflect.GenericArrayType.getGenericComponentType方法的典型用法代碼示例。如果您正苦於以下問題:Java GenericArrayType.getGenericComponentType方法的具體用法?Java GenericArrayType.getGenericComponentType怎麽用?Java GenericArrayType.getGenericComponentType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.lang.reflect.GenericArrayType
的用法示例。
在下文中一共展示了GenericArrayType.getGenericComponentType方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: canonicalize
import java.lang.reflect.GenericArrayType; //導入方法依賴的package包/類
/**
* Returns a type that is functionally equal but not necessarily equal according to {@link
* Object#equals(Object) Object.equals()}.
*/
private static Type canonicalize(Type type) {
if (type instanceof Class) {
Class<?> c = (Class<?>) type;
return c.isArray() ? new GenericArrayTypeImpl(canonicalize(c.getComponentType())) : c;
} else if (type instanceof ParameterizedType) {
if (type instanceof ParameterizedTypeImpl) return type;
ParameterizedType p = (ParameterizedType) type;
return new ParameterizedTypeImpl(p.getOwnerType(),
p.getRawType(), p.getActualTypeArguments());
} else if (type instanceof GenericArrayType) {
if (type instanceof GenericArrayTypeImpl) return type;
GenericArrayType g = (GenericArrayType) type;
return new GenericArrayTypeImpl(g.getGenericComponentType());
} else if (type instanceof WildcardType) {
if (type instanceof WildcardTypeImpl) return type;
WildcardType w = (WildcardType) type;
return new WildcardTypeImpl(w.getUpperBounds(), w.getLowerBounds());
} else {
return type; // This type is unsupported!
}
}
示例2: canonicalize
import java.lang.reflect.GenericArrayType; //導入方法依賴的package包/類
/**
* Returns a type that is functionally equal but not necessarily equal
* according to {@link Object#equals(Object) Object.equals()}. The returned
* type is {@link java.io.Serializable}.
*/
public static Type canonicalize(Type type) {
if (type instanceof Class) {
Class<?> c = (Class<?>) type;
return c.isArray() ? new GenericArrayTypeImpl(canonicalize(c.getComponentType())) : c;
} else if (type instanceof ParameterizedType) {
ParameterizedType p = (ParameterizedType) type;
return new ParameterizedTypeImpl(p.getOwnerType(),
p.getRawType(), p.getActualTypeArguments());
} else if (type instanceof GenericArrayType) {
GenericArrayType g = (GenericArrayType) type;
return new GenericArrayTypeImpl(g.getGenericComponentType());
} else if (type instanceof WildcardType) {
WildcardType w = (WildcardType) type;
return new WildcardTypeImpl(w.getUpperBounds(), w.getLowerBounds());
} else {
// type is either serializable as-is or unsupported
return type;
}
}
示例3: getItemType
import java.lang.reflect.GenericArrayType; //導入方法依賴的package包/類
public TypeInfo getItemType() {
if (type instanceof Class && ((Class)type).isArray() && !byte[].class.equals(type)) {
Type componentType = ((Class)type).getComponentType();
Type genericComponentType = null;
if (genericType!= null && genericType instanceof GenericArrayType) {
GenericArrayType arrayType = (GenericArrayType) type;
genericComponentType = arrayType.getGenericComponentType();
componentType = arrayType.getGenericComponentType();
}
TypeInfo ti =new TypeInfo(tagName, componentType, annotations);
if (genericComponentType != null) ti.setGenericType(genericComponentType);
for(Annotation anno : annotations) if (anno instanceof XmlElementWrapper) ti.wrapperType = this;
return ti;
}
// if (type instanceof Class && java.util.Collection.class.isAssignableFrom((Class)type)) {
Type t = (genericType != null)? genericType : type;
Type base = Utils.REFLECTION_NAVIGATOR.getBaseClass(t, Collection.class);
if ( base != null) {
return new TypeInfo(tagName, Utils.REFLECTION_NAVIGATOR.getTypeArgument(base,0), annotations);
}
return null;
}
示例4: canonicalize
import java.lang.reflect.GenericArrayType; //導入方法依賴的package包/類
/**
* Returns a type that is functionally equal but not necessarily equal
* according to {@link Object#equals(Object) Object.equals()}. The returned
* type is {@link Serializable}.
*/
public static Type canonicalize(Type type) {
if (type instanceof Class) {
Class<?> c = (Class<?>) type;
return c.isArray() ? new GenericArrayTypeImpl(canonicalize(c.getComponentType())) : c;
} else if (type instanceof CompositeType) {
return type;
} else if (type instanceof ParameterizedType) {
ParameterizedType p = (ParameterizedType) type;
return new ParameterizedTypeImpl(p.getOwnerType(),
p.getRawType(), p.getActualTypeArguments());
} else if (type instanceof GenericArrayType) {
GenericArrayType g = (GenericArrayType) type;
return new GenericArrayTypeImpl(g.getGenericComponentType());
} else if (type instanceof WildcardType) {
WildcardType w = (WildcardType) type;
return new WildcardTypeImpl(w.getUpperBounds(), w.getLowerBounds());
} else {
// type is either serializable as-is or unsupported
return type;
}
}
示例5: isAssignableFrom
import java.lang.reflect.GenericArrayType; //導入方法依賴的package包/類
private static boolean isAssignableFrom(Type from, GenericArrayType to) {
Type toGenericComponentType = to.getGenericComponentType();
if (!(toGenericComponentType instanceof ParameterizedType)) {
return true;
}
Type t = from;
if (from instanceof GenericArrayType) {
t = ((GenericArrayType) from).getGenericComponentType();
} else if (from instanceof Class) {
Class<?> classType = (Class) from;
while (classType.isArray()) {
classType = classType.getComponentType();
}
Object t2 = classType;
}
return isAssignableFrom(t, (ParameterizedType) toGenericComponentType, new HashMap());
}
示例6: canonicalize
import java.lang.reflect.GenericArrayType; //導入方法依賴的package包/類
/**
* Returns a type that is functionally equal but not necessarily equal
* according to {@link Object#equals(Object) Object.equals()}. The returned
* type is {@link Serializable}.
*/
public static Type canonicalize(Type type) {
if (type instanceof Class) {
Class<?> c = (Class<?>) type;
return c.isArray() ? new GenericArrayTypeImpl(canonicalize(c.getComponentType())) : c;
} else if (type instanceof ParameterizedType) {
ParameterizedType p = (ParameterizedType) type;
return new ParameterizedTypeImpl(p.getOwnerType(),
p.getRawType(), p.getActualTypeArguments());
} else if (type instanceof GenericArrayType) {
GenericArrayType g = (GenericArrayType) type;
return new GenericArrayTypeImpl(g.getGenericComponentType());
} else if (type instanceof WildcardType) {
WildcardType w = (WildcardType) type;
return new WildcardTypeImpl(w.getUpperBounds(), w.getLowerBounds());
} else {
// type is either serializable as-is or unsupported
return type;
}
}
示例7: isAssignableFrom
import java.lang.reflect.GenericArrayType; //導入方法依賴的package包/類
/**
* Private helper function that performs some assignability checks for
* the provided GenericArrayType.
*/
private static boolean isAssignableFrom(Type from, GenericArrayType to) {
Type toGenericComponentType = to.getGenericComponentType();
if (toGenericComponentType instanceof ParameterizedType) {
Type t = from;
if (from instanceof GenericArrayType) {
t = ((GenericArrayType) from).getGenericComponentType();
} else if (from instanceof Class<?>) {
Class<?> classType = (Class<?>) from;
while (classType.isArray()) {
classType = classType.getComponentType();
}
t = classType;
}
return isAssignableFrom(t, (ParameterizedType) toGenericComponentType,
new HashMap<String, Type>());
}
// No generic defined on "to"; therefore, return true and let other
// checks determine assignability
return true;
}
示例8: getItemType
import java.lang.reflect.GenericArrayType; //導入方法依賴的package包/類
public TypeInfo getItemType() {
// System.out.println("????? TypeInfo " + type);
if (type instanceof Class && ((Class)type).isArray() && !byte[].class.equals(type)) {
Type componentType = ((Class)type).getComponentType();
Type genericComponentType = null;
if (genericType!= null && genericType instanceof GenericArrayType) {
GenericArrayType arrayType = (GenericArrayType) type;
genericComponentType = arrayType.getGenericComponentType();
componentType = arrayType.getGenericComponentType();
}
TypeInfo ti =new TypeInfo(tagName, componentType, annotations);
if (genericComponentType != null) ti.setGenericType(genericComponentType);
return ti;
}
// if (type instanceof Class && java.util.Collection.class.isAssignableFrom((Class)type)) {
Type t = (genericType != null)? genericType : type;
Type base = Utils.REFLECTION_NAVIGATOR.getBaseClass(t, Collection.class);
if ( base != null) {
return new TypeInfo(tagName, Utils.REFLECTION_NAVIGATOR.getTypeArgument(base,0), annotations);
}
return null;
}
示例9: ultimateComponentType
import java.lang.reflect.GenericArrayType; //導入方法依賴的package包/類
private static Type ultimateComponentType(GenericArrayType gat) {
Type component = gat.getGenericComponentType();
if (component instanceof GenericArrayType)
return ultimateComponentType((GenericArrayType) component);
else
return component;
}
示例10: canonicalize
import java.lang.reflect.GenericArrayType; //導入方法依賴的package包/類
/**
* Returns a type that is functionally equal but not necessarily equal
* according to {@link Object#equals(Object) Object.equals()}.
*/
public static Type canonicalize(Type type) {
if (type instanceof ParameterizedTypeImpl
|| type instanceof GenericArrayTypeImpl
|| type instanceof WildcardTypeImpl) {
return type;
} else if (type instanceof ParameterizedType) {
ParameterizedType p = (ParameterizedType) type;
return new ParameterizedTypeImpl(p.getOwnerType(),
p.getRawType(), p.getActualTypeArguments());
} else if (type instanceof GenericArrayType) {
GenericArrayType g = (GenericArrayType) type;
return new GenericArrayTypeImpl(g.getGenericComponentType());
} else if (type instanceof Class && ((Class<?>) type).isArray()) {
Class<?> c = (Class<?>) type;
return new GenericArrayTypeImpl(c.getComponentType());
} else if (type instanceof WildcardType) {
WildcardType w = (WildcardType) type;
return new WildcardTypeImpl(w.getUpperBounds(), w.getLowerBounds());
} else {
// type is either serializable as-is or unsupported
return type;
}
}
示例11: getArrayType
import java.lang.reflect.GenericArrayType; //導入方法依賴的package包/類
public Type getArrayType() {
Class<?> clazz = Cast.as(type, Class.class);
if (clazz != null) {
return clazz.getComponentType();
}
GenericArrayType gat = Cast.as(type, GenericArrayType.class);
if (gat != null) {
return gat.getGenericComponentType();
}
return null;
}
示例12: equals
import java.lang.reflect.GenericArrayType; //導入方法依賴的package包/類
@Override
public boolean equals(Object o) {
if (o instanceof GenericArrayType) {
GenericArrayType that = (GenericArrayType) o;
Type thatComponentType = that.getGenericComponentType();
return componentType == null ? thatComponentType == null : componentType.equals(thatComponentType);
} else {
return false;
}
}
示例13: testResolveToGenericArrayType
import java.lang.reflect.GenericArrayType; //導入方法依賴的package包/類
public void testResolveToGenericArrayType() {
GenericArrayType arrayType = (GenericArrayType)
new Holder<List<int[][]>[]>() {}.getContentType();
ParameterizedType listType = (ParameterizedType)
arrayType.getGenericComponentType();
assertEquals(List.class, listType.getRawType());
assertEquals(Types.newArrayType(int[].class),
listType.getActualTypeArguments()[0]);
}
示例14: equals
import java.lang.reflect.GenericArrayType; //導入方法依賴的package包/類
@Override
public boolean equals(Object o) {
if (o instanceof GenericArrayType) {
GenericArrayType that = (GenericArrayType) o;
Type thatComponentType = that.getGenericComponentType();
return genericComponentType.equals(thatComponentType);
} else
return false;
}
示例15: equals
import java.lang.reflect.GenericArrayType; //導入方法依賴的package包/類
@Override
public boolean equals(Object o) {
if (o instanceof GenericArrayType) {
GenericArrayType that = (GenericArrayType) o;
Type thatComponentType = that.getGenericComponentType();
return genericComponentType == null ?
thatComponentType == null :
genericComponentType.equals(thatComponentType);
} else
return false;
}