MCPcopy
hub / github.com/google/guava / visit

Method visit

guava/src/com/google/common/reflect/TypeVisitor.java:65–93  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers 15

rejectTypeVariablesMethod · 0.45
visitWildcardTypeMethod · 0.45
visitGenericArrayTypeMethod · 0.45
getRawTypesMethod · 0.45
visitTypeVariableMethod · 0.45
populateTypeMappingsMethod · 0.45
getTypeMappingsMethod · 0.45
visitClassMethod · 0.45
visitTypeVariableMethod · 0.45
visitWildcardTypeMethod · 0.45

Calls 7

visitTypeVariableMethod · 0.95
visitWildcardTypeMethod · 0.95
visitClassMethod · 0.95
visitGenericArrayTypeMethod · 0.95
addMethod · 0.65
removeMethod · 0.65

Tested by 10

testVisitNullMethod · 0.36
testVisitClassMethod · 0.36
testVisitTypeVariableMethod · 0.36
testVisitWildcardTypeMethod · 0.36
visitTypeVariableMethod · 0.36
assertVisitedMethod · 0.36