public static ParameterizedType getParameterizedType(Type type) { if (type instanceof ParameterizedType) { return (ParameterizedType)type; } else if (type instanceof Class) { Class<?> classType = (Class<?>)type; return new OwbParametrizedTypeImpl(classType.getDeclaringClass(), classType, classType.getTypeParameters()); } else { throw new IllegalArgumentException(type.getClass().getSimpleName() + " is not supported"); } }
Type[] actualTypes = getActualTypeArguments(); if(actualTypes.length > 0)
@Override public Type getType() { if (selectType != null && ParameterizedType.class.isInstance(selectType)) { ParameterizedType parameterizedType = ParameterizedType.class.cast(selectType); Type rawType = parameterizedType.getRawType(); if (rawType == type) { return selectType; } else if (rawType == List.class && type == ArrayList.class) { return new OwbParametrizedTypeImpl(parameterizedType.getOwnerType(), type, parameterizedType.getActualTypeArguments()); } else if (rawType == Set.class && type == HashSet.class) { return new OwbParametrizedTypeImpl(parameterizedType.getOwnerType(), type, parameterizedType.getActualTypeArguments()); } else if (rawType == Map.class && (type == HashMap.class || type == ConcurrentHashMap.class || type == TreeMap.class)) { return new OwbParametrizedTypeImpl(parameterizedType.getOwnerType(), type, parameterizedType.getActualTypeArguments()); } // TODO: better handling of these kind of types, the idea is to check selectType is a parent of type and param number is == } return type; }
public void validEventType(Type eventType, Type metadataType) { EventCacheKey key = new EventCacheKey(eventType, metadataType); if (validEventType.containsKey(key)) { return; } if (GenericsUtil.hasTypeParameters(eventType)) { Type et = GenericsUtil.resolveType(GenericsUtil.getParameterizedType(eventType), metadataType); if (OwbParametrizedTypeImpl.class.isInstance(et)) { for (Type t : OwbParametrizedTypeImpl.class.cast(et).getActualTypeArguments()) { if (OwbWildcardTypeImpl.class.isInstance(t)) { throw new IllegalArgumentException("TypeVariable forbidden for events"); } } } } validEventType.putIfAbsent(key, true); // we don't care about the value but that's thread safe to use this map }
bean, new OwbParametrizedTypeImpl(null, LifecycleListener.class, paramType), bm.createCreationalContext(null))))) .flatMap(s -> s).toArray(LifecycleListener[]::new);
return new OwbParametrizedTypeImpl(parameterizedType.getOwnerType(), parameterizedType.getRawType(), resolvedTypeArguments);
Type directSubtype = new OwbParametrizedTypeImpl(directSubclass.getDeclaringClass(), directSubclass, typeArguments); return resolveTypeVariable(variable, directSubtype, seen); genericSuperclass = new OwbParametrizedTypeImpl(superclass.getDeclaringClass(), superclass, getRawTypes(superclass.getTypeParameters())); genericSuperclass = new OwbParametrizedTypeImpl(genericSupertype.getOwnerType(), genericSupertype.getRawType(), typeArguments);