private void addExposedTypes(Field field, Class<?> cause) { addExposedTypes(field.getGenericType(), cause); for (Annotation annotation : field.getDeclaredAnnotations()) { LOG.debug( "Adding exposed types from {}, which is an annotation on field {}", annotation, field); addExposedTypes(annotation.annotationType(), cause); } }
/** * Adds any references learned by following a link from {@code cause} to {@code type}. This will * dispatch according to the concrete {@code Type} implementation. See the other overloads of * {@code addExposedTypes} for their details. */ private void addExposedTypes(Type type, Class<?> cause) { if (type instanceof TypeVariable) { LOG.debug("Adding exposed types from {}, which is a type variable", type); addExposedTypes((TypeVariable) type, cause); } else if (type instanceof WildcardType) { LOG.debug("Adding exposed types from {}, which is a wildcard type", type); addExposedTypes((WildcardType) type, cause); } else if (type instanceof GenericArrayType) { LOG.debug("Adding exposed types from {}, which is a generic array type", type); addExposedTypes((GenericArrayType) type, cause); } else if (type instanceof ParameterizedType) { LOG.debug("Adding exposed types from {}, which is a parameterized type", type); addExposedTypes((ParameterizedType) type, cause); } else if (type instanceof Class) { LOG.debug("Adding exposed types from {}, which is a class", type); addExposedTypes((Class) type, cause); } else { throw new IllegalArgumentException("Unknown implementation of Type"); } }
/** * Adds any types exposed to this set. These will come from the (possibly absent) bounds on the * wildcard. */ private void addExposedTypes(WildcardType type, Class<?> cause) { visit(type); for (Type lowerBound : type.getLowerBounds()) { LOG.debug( "Adding exposed types from {}, which is a type lower bound on wildcard type {}", lowerBound, type); addExposedTypes(lowerBound, cause); } for (Type upperBound : type.getUpperBounds()) { LOG.debug( "Adding exposed types from {}, which is a type upper bound on wildcard type {}", upperBound, type); addExposedTypes(upperBound, cause); } }
private void addExposedTypes(Parameter parameter, Class<?> cause) { LOG.debug( "Adding exposed types from {}, which is the type of parameter {}", parameter.getType(), parameter); addExposedTypes(parameter.getType(), cause); for (Annotation annotation : parameter.getAnnotations()) { LOG.debug( "Adding exposed types from {}, which is an annotation on parameter {}", annotation, parameter); addExposedTypes(annotation.annotationType(), cause); } }
/** See {@link #addExposedTypes(Type, Class)}. */ private void addExposedTypes(TypeToken type, Class<?> cause) { LOG.debug( "Adding exposed types from {}, which is the type in type token {}", type.getType(), type); addExposedTypes(type.getType(), cause); }
/** * Adds any types exposed from the given array type. The array type itself is not added. The cause * of the exposure of the underlying type is considered whatever type exposed the array type. */ private void addExposedTypes(GenericArrayType type, Class<?> cause) { if (done(type)) { return; } visit(type); LOG.debug( "Adding exposed types from {}, which is the component type on generic array type {}", type.getGenericComponentType(), type); addExposedTypes(type.getGenericComponentType(), cause); }
private void addExposedTypes(Invokable<?, ?> invokable, Class<?> cause) { addExposedTypes(invokable.getReturnType(), cause); for (Annotation annotation : invokable.getAnnotations()) { LOG.debug( "Adding exposed types from {}, which is an annotation on invokable {}", annotation, invokable); addExposedTypes(annotation.annotationType(), cause); } for (Parameter parameter : invokable.getParameters()) { LOG.debug( "Adding exposed types from {}, which is a parameter on invokable {}", parameter, invokable); addExposedTypes(parameter, cause); } for (TypeToken<?> exceptionType : invokable.getExceptionTypes()) { LOG.debug( "Adding exposed types from {}, which is an exception type on invokable {}", exceptionType, invokable); addExposedTypes(exceptionType, cause); } }
/** * Adds any types exposed to this set. These will come from the (possibly absent) bounds on the * type variable. */ private void addExposedTypes(TypeVariable type, Class<?> cause) { if (done(type)) { return; } visit(type); for (Type bound : type.getBounds()) { LOG.debug("Adding exposed types from {}, which is a type bound on {}", bound, type); addExposedTypes(bound, cause); } }
type.getRawType(), type); addExposedTypes(type.getRawType(), cause); for (Type typeArg : type.getActualTypeArguments()) { LOG.debug( typeArg, type); addExposedTypes(typeArg, cause);
/** See {@link #getExposedToExposers}. */ private void constructExposedToExposers() { visited = Sets.newHashSet(); exposedToExposers = Multimaps.newSetMultimap( Maps.<Class<?>, Collection<Class<?>>>newHashMap(), Sets::newHashSet); for (Class<?> clazz : rootClasses) { addExposedTypes(clazz, null); } }
LOG.debug( "Adding exposed types from {}, which is a super type token on {}", superType, clazz); addExposedTypes(superType, clazz); innerClass, clazz); addExposedTypes(innerClass, clazz); if (exposed(field.getModifiers())) { LOG.debug("Adding exposed types from {}, which is an exposed field on {}", field, clazz); addExposedTypes(field, clazz); LOG.debug( "Adding exposed types from {}, which is an exposed invokable on {}", invokable, clazz); addExposedTypes(invokable, clazz);