public static boolean containsTypeVariable(Type type) { type = Types.getCanonicalType(type); if (type instanceof TypeVariable<?>) { return true; } if (type instanceof ParameterizedType) { ParameterizedType parameterizedType = (ParameterizedType) type; for (Type t : parameterizedType.getActualTypeArguments()) { if (containsTypeVariable(t)) { return true; } } } if (type instanceof GenericArrayType) { GenericArrayType genericArrayType = (GenericArrayType) type; return containsTypeVariable(genericArrayType.getGenericComponentType()); } return false; }
public static boolean containsTypeVariable(Type type) { type = Types.getCanonicalType(type); if (type instanceof TypeVariable<?>) { return true; } if (type instanceof ParameterizedType) { ParameterizedType parameterizedType = (ParameterizedType) type; for (Type t : parameterizedType.getActualTypeArguments()) { if (containsTypeVariable(t)) { return true; } } } if (type instanceof GenericArrayType) { GenericArrayType genericArrayType = (GenericArrayType) type; return containsTypeVariable(genericArrayType.getGenericComponentType()); } return false; }
public static boolean containsTypeVariable(Type type) { type = Types.getCanonicalType(type); if (type instanceof TypeVariable<?>) { return true; } if (type instanceof ParameterizedType) { ParameterizedType parameterizedType = (ParameterizedType) type; for (Type t : parameterizedType.getActualTypeArguments()) { if (containsTypeVariable(t)) { return true; } } } if (type instanceof GenericArrayType) { GenericArrayType genericArrayType = (GenericArrayType) type; return containsTypeVariable(genericArrayType.getGenericComponentType()); } return false; }
public static boolean containsTypeVariable(Type type) { type = Types.getCanonicalType(type); if (type instanceof TypeVariable<?>) { return true; } if (type instanceof ParameterizedType) { ParameterizedType parameterizedType = (ParameterizedType) type; for (Type t : parameterizedType.getActualTypeArguments()) { if (containsTypeVariable(t)) { return true; } } } if (type instanceof GenericArrayType) { GenericArrayType genericArrayType = (GenericArrayType) type; return containsTypeVariable(genericArrayType.getGenericComponentType()); } return false; }
public static boolean containsTypeVariable(Type type) { type = Types.getCanonicalType(type); if (type instanceof TypeVariable<?>) { return true; } if (type instanceof ParameterizedType) { ParameterizedType parameterizedType = (ParameterizedType) type; for (Type t : parameterizedType.getActualTypeArguments()) { if (containsTypeVariable(t)) { return true; } } } if (type instanceof GenericArrayType) { GenericArrayType genericArrayType = (GenericArrayType) type; return containsTypeVariable(genericArrayType.getGenericComponentType()); } return false; }
public static boolean containsTypeVariable(Type type) { type = Types.getCanonicalType(type); if (type instanceof TypeVariable<?>) { return true; } if (type instanceof ParameterizedType) { ParameterizedType parameterizedType = (ParameterizedType) type; for (Type t : parameterizedType.getActualTypeArguments()) { if (containsTypeVariable(t)) { return true; } } } if (type instanceof GenericArrayType) { GenericArrayType genericArrayType = (GenericArrayType) type; return containsTypeVariable(genericArrayType.getGenericComponentType()); } return false; }
private boolean matches(InvokableAnnotatedMethod<?> decoratedMethod, Method candidate) { if (candidate.getParameterTypes().length != decoratedMethod.getParameters().size()) { return false; } if (!candidate.getName().equals(decoratedMethod.getJavaMember().getName())) { return false; } for (int i = 0; i < candidate.getParameterTypes().length; i++) { Type decoratedMethodParamType = decoratedMethod.getJavaMember().getGenericParameterTypes()[i]; Type candidateParamType = candidate.getGenericParameterTypes()[i]; if (Types.containsTypeVariable(decoratedMethodParamType) || Types.containsTypeVariable(candidateParamType)) { if (!decoratedMethod.getJavaMember().getParameterTypes()[i].isAssignableFrom(candidate.getParameterTypes()[i])) { return false; } } else { if (!CovariantTypes.isAssignableFrom(decoratedMethodParamType, candidateParamType)) { return false; } } } return true; }
private boolean matches(InvokableAnnotatedMethod<?> decoratedMethod, Method candidate) { if (candidate.getParameterTypes().length != decoratedMethod.getParameters().size()) { return false; } if (!candidate.getName().equals(decoratedMethod.getJavaMember().getName())) { return false; } for (int i = 0; i < candidate.getParameterTypes().length; i++) { Type decoratedMethodParamType = decoratedMethod.getJavaMember().getGenericParameterTypes()[i]; Type candidateParamType = candidate.getGenericParameterTypes()[i]; if (Types.containsTypeVariable(decoratedMethodParamType) || Types.containsTypeVariable(candidateParamType)) { if (!decoratedMethod.getJavaMember().getParameterTypes()[i].isAssignableFrom(candidate.getParameterTypes()[i])) { return false; } } else { if (!CovariantTypes.isAssignableFrom(decoratedMethodParamType, candidateParamType)) { return false; } } } return true; }
private boolean matches(InvokableAnnotatedMethod<?> decoratedMethod, Method candidate) { if (candidate.getParameterTypes().length != decoratedMethod.getParameters().size()) { return false; } if (!candidate.getName().equals(decoratedMethod.getJavaMember().getName())) { return false; } for (int i = 0; i < candidate.getParameterTypes().length; i++) { Type decoratedMethodParamType = decoratedMethod.getJavaMember().getGenericParameterTypes()[i]; Type candidateParamType = candidate.getGenericParameterTypes()[i]; if (Types.containsTypeVariable(decoratedMethodParamType) || Types.containsTypeVariable(candidateParamType)) { if (!decoratedMethod.getJavaMember().getParameterTypes()[i].isAssignableFrom(candidate.getParameterTypes()[i])) { return false; } } else { if (!CovariantTypes.isAssignableFrom(decoratedMethodParamType, candidateParamType)) { return false; } } } return true; }
@Override public RuntimeException apply(Type eventType) { Type resolvedType = Types.getCanonicalType(eventType); /* * If the runtime type of the event object contains a type variable, the container must throw an IllegalArgumentException. */ if (Types.containsTypeVariable(resolvedType)) { return UtilLogger.LOG.typeParameterNotAllowedInEventType(eventType); } /* * If the runtime type of the event object is assignable to the type of a container lifecycle event, IllegalArgumentException is thrown. */ Class<?> resolvedClass = Reflections.getRawType(eventType); for (Class<?> containerEventType : Observers.CONTAINER_LIFECYCLE_EVENT_CANONICAL_SUPERTYPES) { if (containerEventType.isAssignableFrom(resolvedClass)) { return UtilLogger.LOG.eventTypeNotAllowed(eventType); } } return NO_EXCEPTION_MARKER; } }
@Override public RuntimeException apply(Type eventType) { Type resolvedType = Types.getCanonicalType(eventType); /* * If the runtime type of the event object contains a type variable, the container must throw an IllegalArgumentException. */ if (Types.containsTypeVariable(resolvedType)) { return UtilLogger.LOG.typeParameterNotAllowedInEventType(eventType); } /* * If the runtime type of the event object is assignable to the type of a container lifecycle event, IllegalArgumentException is thrown. */ Class<?> resolvedClass = Reflections.getRawType(eventType); for (Class<?> containerEventType : Observers.CONTAINER_LIFECYCLE_EVENT_CANONICAL_SUPERTYPES) { if (containerEventType.isAssignableFrom(resolvedClass)) { return UtilLogger.LOG.eventTypeNotAllowed(eventType); } } return NO_EXCEPTION_MARKER; } }
@Override public RuntimeException apply(Type eventType) { Type resolvedType = Types.getCanonicalType(eventType); /* * If the runtime type of the event object contains a type variable, the container must throw an IllegalArgumentException. */ if (Types.containsTypeVariable(resolvedType)) { return UtilLogger.LOG.typeParameterNotAllowedInEventType(eventType); } /* * If the runtime type of the event object is assignable to the type of a container lifecycle event, IllegalArgumentException is thrown. */ Class<?> resolvedClass = Reflections.getRawType(eventType); for (Class<?> containerEventType : Observers.CONTAINER_LIFECYCLE_EVENT_CANONICAL_SUPERTYPES) { if (containerEventType.isAssignableFrom(resolvedClass)) { return UtilLogger.LOG.eventTypeNotAllowed(eventType); } } return NO_EXCEPTION_MARKER; } }
@Override public RuntimeException apply(Type eventType) { Type resolvedType = Types.getCanonicalType(eventType); /* * If the runtime type of the event object contains a type variable, the container must throw an IllegalArgumentException. */ if (Types.containsTypeVariable(resolvedType)) { return UtilLogger.LOG.typeParameterNotAllowedInEventType(eventType); } /* * If the runtime type of the event object is assignable to the type of a container lifecycle event, IllegalArgumentException * is thrown. */ Class<?> resolvedClass = Reflections.getRawType(eventType); for (Class<?> containerEventType : Observers.CONTAINER_LIFECYCLE_EVENT_CANONICAL_SUPERTYPES) { if (containerEventType.isAssignableFrom(resolvedClass)) { return UtilLogger.LOG.eventTypeNotAllowed(eventType); } } return NO_EXCEPTION_MARKER; } }
@Override public RuntimeException apply(Type eventType) { Type resolvedType = Types.getCanonicalType(eventType); /* * If the runtime type of the event object contains a type variable, the container must throw an IllegalArgumentException. */ if (Types.containsTypeVariable(resolvedType)) { return UtilLogger.LOG.typeParameterNotAllowedInEventType(eventType); } /* * If the runtime type of the event object is assignable to the type of a container lifecycle event, IllegalArgumentException is thrown. */ Class<?> resolvedClass = Reflections.getRawType(eventType); for (Class<?> containerEventType : Observers.CONTAINER_LIFECYCLE_EVENT_CANONICAL_SUPERTYPES) { if (containerEventType.isAssignableFrom(resolvedClass)) { return UtilLogger.LOG.eventTypeNotAllowed(eventType); } } return NO_EXCEPTION_MARKER; } }
protected Type getEventType(Class<?> runtimeType) { Type resolvedType = runtimeType; if (Types.containsTypeVariable(resolvedType)) { /* * If the container is unable to resolve the parameterized type of the event object, it uses the specified type to infer the parameterized type of the event types. */ resolvedType = injectionPointTypeHierarchy.resolveType(resolvedType); } if (Types.containsTypeVariable(resolvedType)) { /* * Examining the hierarchy of the specified type did not help. This may still be one of the cases when combining the * event type and the specified type reveals the actual values for type variables. Let's try that. */ Type canonicalEventType = Types.getCanonicalType(runtimeType); TypeResolver objectTypeResolver = new EventObjectTypeResolverBuilder(injectionPointTypeHierarchy.getResolver() .getResolvedTypeVariables(), new HierarchyDiscovery(canonicalEventType).getResolver() .getResolvedTypeVariables()).build(); resolvedType = objectTypeResolver.resolveType(canonicalEventType); } return resolvedType; }
protected Type getEventType(Class<?> runtimeType) { Type resolvedType = runtimeType; if (Types.containsTypeVariable(resolvedType)) { /* * If the container is unable to resolve the parameterized type of the event object, it uses the specified type to infer the parameterized type of the event types. */ resolvedType = injectionPointTypeHierarchy.resolveType(resolvedType); } if (Types.containsTypeVariable(resolvedType)) { /* * Examining the hierarchy of the specified type did not help. This may still be one of the cases when combining the * event type and the specified type reveals the actual values for type variables. Let's try that. */ Type canonicalEventType = Types.getCanonicalType(runtimeType); TypeResolver objectTypeResolver = new EventObjectTypeResolverBuilder(injectionPointTypeHierarchy.getResolver() .getResolvedTypeVariables(), new HierarchyDiscovery(canonicalEventType).getResolver() .getResolvedTypeVariables()).build(); resolvedType = objectTypeResolver.resolveType(canonicalEventType); } return resolvedType; }
protected Type getEventType(Class<?> runtimeType) { Type resolvedType = runtimeType; if (Types.containsTypeVariable(resolvedType)) { /* * If the container is unable to resolve the parameterized type of the event object, it uses the specified type to infer the parameterized type of the event types. */ resolvedType = injectionPointTypeHierarchy.resolveType(resolvedType); } if (Types.containsTypeVariable(resolvedType)) { /* * Examining the hierarchy of the specified type did not help. This may still be one of the cases when combining the * event type and the specified type reveals the actual values for type variables. Let's try that. */ Type canonicalEventType = Types.getCanonicalType(runtimeType); TypeResolver objectTypeResolver = new EventObjectTypeResolverBuilder(injectionPointTypeHierarchy.getResolver() .getResolvedTypeVariables(), new HierarchyDiscovery(canonicalEventType).getResolver() .getResolvedTypeVariables()).build(); resolvedType = objectTypeResolver.resolveType(canonicalEventType); } return resolvedType; }
protected Type getEventType(Class<?> runtimeType) { Type resolvedType = runtimeType; if (Types.containsTypeVariable(resolvedType)) { /* * If the container is unable to resolve the parameterized type of the event object, it uses the specified type to infer the parameterized type of the event types. */ resolvedType = injectionPointTypeHierarchy.resolveType(resolvedType); } if (Types.containsTypeVariable(resolvedType)) { /* * Examining the hierarchy of the specified type did not help. This may still be one of the cases when combining the * event type and the specified type reveals the actual values for type variables. Let's try that. */ Type canonicalEventType = Types.getCanonicalType(runtimeType); TypeResolver objectTypeResolver = new EventObjectTypeResolverBuilder(injectionPointTypeHierarchy.getResolver() .getResolvedTypeVariables(), new HierarchyDiscovery(canonicalEventType).getResolver() .getResolvedTypeVariables()).build(); resolvedType = objectTypeResolver.resolveType(canonicalEventType); } return resolvedType; }
protected Type getEventType(Class<?> runtimeType) { Type resolvedType = runtimeType; if (Types.containsTypeVariable(resolvedType)) { /* * If the container is unable to resolve the parameterized type of the event object, it uses the specified type to infer the parameterized type of the event types. */ resolvedType = injectionPointTypeHierarchy.resolveType(resolvedType); } if (Types.containsTypeVariable(resolvedType)) { /* * Examining the hierarchy of the specified type did not help. This may still be one of the cases when combining the * event type and the specified type reveals the actual values for type variables. Let's try that. */ Type canonicalEventType = Types.getCanonicalType(runtimeType); TypeResolver objectTypeResolver = new EventObjectTypeResolverBuilder(injectionPointTypeHierarchy.getResolver() .getResolvedTypeVariables(), new HierarchyDiscovery(canonicalEventType).getResolver() .getResolvedTypeVariables()).build(); resolvedType = objectTypeResolver.resolveType(canonicalEventType); } return resolvedType; }
protected Type getEventType(Class<?> runtimeType) { Type resolvedType = runtimeType; if (Types.containsTypeVariable(resolvedType)) { /* * If the container is unable to resolve the parameterized type of the event object, it uses the specified type to infer the parameterized type of the event types. */ resolvedType = injectionPointTypeHierarchy.resolveType(resolvedType); } if (Types.containsTypeVariable(resolvedType)) { /* * Examining the hierarchy of the specified type did not help. This may still be one of the cases when combining the * event type and the specified type reveals the actual values for type variables. Let's try that. */ Type canonicalEventType = Types.getCanonicalType(runtimeType); TypeResolver objectTypeResolver = new EventObjectTypeResolverBuilder(injectionPointTypeHierarchy.getResolver() .getResolvedTypeVariables(), new HierarchyDiscovery(canonicalEventType).getResolver() .getResolvedTypeVariables()).build(); resolvedType = objectTypeResolver.resolveType(canonicalEventType); } return resolvedType; }