use of java.lang.reflect.ParameterizedType in project flink by apache.
the class ReflectionUtil method getTemplateTypes.
public static Class<?>[] getTemplateTypes(ParameterizedType paramterizedType) {
Class<?>[] types = new Class<?>[paramterizedType.getActualTypeArguments().length];
int i = 0;
for (Type templateArgument : paramterizedType.getActualTypeArguments()) {
assert templateArgument instanceof Class<?>;
types[i++] = (Class<?>) templateArgument;
}
return types;
}
use of java.lang.reflect.ParameterizedType in project flink by apache.
the class ReflectionUtil method getTemplateTypes.
public static Class<?>[] getTemplateTypes(Class<?> clazz) {
Type type = clazz.getGenericSuperclass();
assert (type instanceof ParameterizedType);
ParameterizedType paramterizedType = (ParameterizedType) type;
Class<?>[] types = new Class<?>[paramterizedType.getActualTypeArguments().length];
int i = 0;
for (Type templateArgument : paramterizedType.getActualTypeArguments()) {
assert (templateArgument instanceof Class<?>);
types[i++] = (Class<?>) templateArgument;
}
return types;
}
use of java.lang.reflect.ParameterizedType in project flink by apache.
the class ReflectionUtil method getFullTemplateType.
/**
* Extract the full type information from the given type.
*
* @param type to be analyzed
* @return Full type information describing the given type
*/
public static FullTypeInfo getFullTemplateType(Type type) {
if (type instanceof ParameterizedType) {
ParameterizedType parameterizedType = (ParameterizedType) type;
FullTypeInfo[] templateTypeInfos = new FullTypeInfo[parameterizedType.getActualTypeArguments().length];
for (int i = 0; i < parameterizedType.getActualTypeArguments().length; i++) {
templateTypeInfos[i] = getFullTemplateType(parameterizedType.getActualTypeArguments()[i]);
}
return new FullTypeInfo((Class<?>) parameterizedType.getRawType(), templateTypeInfos);
} else {
return new FullTypeInfo((Class<?>) type, null);
}
}
use of java.lang.reflect.ParameterizedType in project camel by apache.
the class CdiCamelExtension method beans.
private void beans(@Observes ProcessBean<?> pb, BeanManager manager) {
cdiBeans.add(pb.getBean());
// Lookup for CDI event endpoint injection points
pb.getBean().getInjectionPoints().stream().filter(ip -> CdiEventEndpoint.class.equals(getRawType(ip.getType()))).forEach(ip -> {
Type type = ip.getType() instanceof ParameterizedType ? ((ParameterizedType) ip.getType()).getActualTypeArguments()[0] : Object.class;
String uri = eventEndpointUri(type, ip.getQualifiers());
cdiEventEndpoints.put(uri, new CdiEventEndpoint<>(uri, type, ip.getQualifiers(), manager));
});
}
use of java.lang.reflect.ParameterizedType in project Genius-Android by qiujuer.
the class Reflector method getClass.
/**
* Get the underlying class for a type, or null if the type is a variable
* type.
*
* @param type the type
* @return the underlying class
*/
public static Class<?> getClass(Type type) {
if (type instanceof Class) {
return (Class) type;
} else if (type instanceof ParameterizedType) {
return getClass(((ParameterizedType) type).getRawType());
} else if (type instanceof GenericArrayType) {
Type componentType = ((GenericArrayType) type).getGenericComponentType();
Class<?> componentClass = getClass(componentType);
if (componentClass != null) {
return Array.newInstance(componentClass, 0).getClass();
} else {
return null;
}
} else {
return null;
}
}
Aggregations