Visits the given types. Null types are ignored. This allows subclasses to call {@code visit(parameterizedType.getOwnerType())} safely without having to check nulls.
(@Nullable Type... types)
| 63 | * visit(parameterizedType.getOwnerType())} safely without having to check nulls. |
| 64 | */ |
| 65 | public final void visit(@Nullable Type... types) { |
| 66 | for (Type type : types) { |
| 67 | if (type == null || !visited.add(type)) { |
| 68 | // null owner type, or already visited; |
| 69 | continue; |
| 70 | } |
| 71 | boolean succeeded = false; |
| 72 | try { |
| 73 | if (type instanceof TypeVariable) { |
| 74 | visitTypeVariable((TypeVariable<?>) type); |
| 75 | } else if (type instanceof WildcardType) { |
| 76 | visitWildcardType((WildcardType) type); |
| 77 | } else if (type instanceof ParameterizedType) { |
| 78 | visitParameterizedType((ParameterizedType) type); |
| 79 | } else if (type instanceof Class) { |
| 80 | visitClass((Class<?>) type); |
| 81 | } else if (type instanceof GenericArrayType) { |
| 82 | visitGenericArrayType((GenericArrayType) type); |
| 83 | } else { |
| 84 | throw new AssertionError("Unknown type: " + type); |
| 85 | } |
| 86 | succeeded = true; |
| 87 | } finally { |
| 88 | if (!succeeded) { // When the visitation failed, we don't want to ignore the second. |
| 89 | visited.remove(type); |
| 90 | } |
| 91 | } |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | void visitClass(Class<?> t) {} |
| 96 |