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

Method getSubtype

output/java_guava/1.4.18/TypeToken.java:412–430  ·  view source on GitHub ↗

Returns subtype of this with subclass as the raw class. For example, if this is Iterable and subclass is List, List is returned.

(Class<?> subclass)

Source from the content-addressed store, hash-verified

410
411
412 public final TypeToken<? extends T> getSubtype(Class<?> subclass) {
413 checkArgument(
414!(runtimeType instanceof TypeVariable),
415"Cannot get subtype of type variable <%s>",
416this);
417 if (runtimeType instanceof WildcardType) {
418 return getSubtypeFromLowerBounds(subclass, ((WildcardType) runtimeType).getLowerBounds());
419 }
420 // unwrap array type if necessary
421 if (isArray()) {
422 return getArraySubtype(subclass);
423 }
424 // At this point, it's either a raw class or parameterized type.
425 checkArgument(getRawType().isAssignableFrom(subclass), "%s isn't a subclass of %s", subclass, this);
426 Type resolvedTypeArgs = resolveTypeArgsForSubclass(subclass);
427 @SuppressWarnings("unchecked") // guarded by the isAssignableFrom() statement above
428 TypeToken<? extends T> subtype = (TypeToken<? extends T>) of(resolvedTypeArgs);
429 return subtype;
430 }
431
432 /**
433 * Returns true if this type is a supertype of the given {@code type}. "Supertype" is defined

Callers 2

getArraySubtypeMethod · 0.45

Calls 8

isArrayMethod · 0.95
getArraySubtypeMethod · 0.95
getRawTypeMethod · 0.95
ofMethod · 0.95
checkArgumentMethod · 0.45
getLowerBoundsMethod · 0.45

Tested by

no test coverage detected