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

Method is

android/guava/src/com/google/common/reflect/TypeToken.java:984–999  ·  view source on GitHub ↗

{@code A.is(B)} is defined as {@code Foo<A>.isSubtypeOf(Foo<B>)}. <p>Specifically, returns true if any of the following conditions is met: <ol> <li>'this' and {@code formalType} are equal. <li>'this' and {@code formalType} have equal canonical form. <li>{@code formalType} is {@code <? extend

(Type formalType, TypeVariable<?> declaration)

Source from the content-addressed store, hash-verified

982 * bound when {@code formalType} is a wildcard with implicit upper bound.
983 */
984 private boolean is(Type formalType, TypeVariable<?> declaration) {
985 if (runtimeType.equals(formalType)) {
986 return true;
987 }
988 if (formalType instanceof WildcardType) {
989 WildcardType your = canonicalizeWildcardType(declaration, (WildcardType) formalType);
990 // if "formalType" is <? extends Foo>, "this" can be:
991 // Foo, SubFoo, <? extends Foo>, <? extends SubFoo>, <T extends Foo> or
992 // <T extends SubFoo>.
993 // if "formalType" is <? super Foo>, "this" can be:
994 // Foo, SuperFoo, <? super Foo> or <? super SuperFoo>.
995 return every(your.getUpperBounds()).isSupertypeOf(runtimeType)
996 && every(your.getLowerBounds()).isSubtypeOf(runtimeType);
997 }
998 return canonicalizeWildcardsInType(runtimeType).equals(canonicalizeWildcardsInType(formalType));
999 }
1000
1001 /**
1002 * In reflection, {@code Foo<?>.getUpperBounds()[0]} is always {@code Object.class}, even when Foo

Callers 1

Calls 8

everyMethod · 0.95
equalsMethod · 0.65
isSupertypeOfMethod · 0.45
getUpperBoundsMethod · 0.45
isSubtypeOfMethod · 0.45
getLowerBoundsMethod · 0.45

Tested by

no test coverage detected