MCPcopy Create free account
hub / github.com/antlr/codebuff / getGenericSuperclass

Method getGenericSuperclass

output/java_guava/1.4.17/TypeToken.java:294–310  ·  view source on GitHub ↗

Returns the generic superclass of this type or null if the type represents Object or an interface. This method is similar but different from Class#getGenericSuperclass. For example, new TypeToken () {.getGenericSuperclass()} will return {@code new Type

()

Source from the content-addressed store, hash-verified

292 */
293
294 @Nullable final TypeToken<? super T> getGenericSuperclass() {
295 if (runtimeType instanceof TypeVariable) {
296 // First bound is always the super class, if one exists.
297 return boundAsSuperclass(((TypeVariable<?>) runtimeType).getBounds() [0]);
298 }
299 if (runtimeType instanceof WildcardType) {
300 // wildcard has one and only one upper bound.
301 return boundAsSuperclass(((WildcardType) runtimeType).getUpperBounds() [0]);
302 }
303 Type superclass = getRawType().getGenericSuperclass();
304 if (superclass == null) {
305 return null;
306 }
307 @SuppressWarnings("unchecked") // super class of T
308 TypeToken<? super T> superToken = (TypeToken<? super T>) resolveSupertype(superclass);
309 return superToken;
310 }
311
312 @Nullable
313 private TypeToken<? super T> boundAsSuperclass(Type bound) {

Callers 4

captureMethod · 0.45
getSuperclassMethod · 0.45
visitClassMethod · 0.45
detectJvmBehaviorMethod · 0.45

Calls 5

boundAsSuperclassMethod · 0.95
getRawTypeMethod · 0.95
resolveSupertypeMethod · 0.95
getBoundsMethod · 0.45
getUpperBoundsMethod · 0.45

Tested by

no test coverage detected