本文整理了Java中com.google.common.reflect.TypeToken.canonicalizeWildcardType()
方法的一些代码示例,展示了TypeToken.canonicalizeWildcardType()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TypeToken.canonicalizeWildcardType()
方法的具体详情如下:
包路径:com.google.common.reflect.TypeToken
类名称:TypeToken
方法名:canonicalizeWildcardType
暂无
代码示例来源:origin: google/guava
/**
* In reflection, {@code Foo<?>.getUpperBounds()[0]} is always {@code Object.class}, even when Foo
* is defined as {@code Foo<T extends String>}. Thus directly calling {@code <?>.is(String.class)}
* will return false. To mitigate, we canonicalize wildcards by enforcing the following
* invariants:
* <ol>
* <li>{@code canonicalize(t)} always produces the equal result for equivalent types. For example
* both {@code Enum<?>} and {@code Enum<? extends Enum<?>>} canonicalize to
* {@code Enum<? extends Enum<E>}.
* <li>{@code canonicalize(t)} produces a "literal" supertype of t.
* For example: {@code Enum<? extends Enum<?>>} canonicalizes to {@code Enum<?>}, which is
* a supertype (if we disregard the upper bound is implicitly an Enum too).
* <li>If {@code canonicalize(A) == canonicalize(B)}, then {@code Foo<A>.isSubtypeOf(Foo<B>)} and
* vice versa. i.e. {@code A.is(B)} and {@code B.is(A)}.
* <li>{@code canonicalize(canonicalize(A)) == canonicalize(A)}.
* </ol>
*/
private static Type canonicalizeTypeArg(TypeVariable<?> declaration, Type typeArg) {
return typeArg instanceof WildcardType
? canonicalizeWildcardType(declaration, ((WildcardType) typeArg))
: canonicalizeWildcardsInType(typeArg);
}
代码示例来源:origin: google/j2objc
/**
* In reflection, {@code Foo<?>.getUpperBounds()[0]} is always {@code Object.class}, even when Foo
* is defined as {@code Foo<T extends String>}. Thus directly calling {@code <?>.is(String.class)}
* will return false. To mitigate, we canonicalize wildcards by enforcing the following
* invariants:
* <ol>
* <li>{@code canonicalize(t)} always produces the equal result for equivalent types. For example
* both {@code Enum<?>} and {@code Enum<? extends Enum<?>>} canonicalize to
* {@code Enum<? extends Enum<E>}.
* <li>{@code canonicalize(t)} produces a "literal" supertype of t.
* For example: {@code Enum<? extends Enum<?>>} canonicalizes to {@code Enum<?>}, which is
* a supertype (if we disregard the upper bound is implicitly an Enum too).
* <li>If {@code canonicalize(A) == canonicalize(B)}, then {@code Foo<A>.isSubtypeOf(Foo<B>)} and
* vice versa. i.e. {@code A.is(B)} and {@code B.is(A)}.
* <li>{@code canonicalize(canonicalize(A)) == canonicalize(A)}.
* </ol>
*/
private static Type canonicalizeTypeArg(TypeVariable<?> declaration, Type typeArg) {
return typeArg instanceof WildcardType
? canonicalizeWildcardType(declaration, ((WildcardType) typeArg))
: canonicalizeWildcardsInType(typeArg);
}
代码示例来源:origin: wildfly/wildfly
/**
* In reflection, {@code Foo<?>.getUpperBounds()[0]} is always {@code Object.class}, even when Foo
* is defined as {@code Foo<T extends String>}. Thus directly calling {@code <?>.is(String.class)}
* will return false. To mitigate, we canonicalize wildcards by enforcing the following
* invariants:
* <ol>
* <li>{@code canonicalize(t)} always produces the equal result for equivalent types. For example
* both {@code Enum<?>} and {@code Enum<? extends Enum<?>>} canonicalize to
* {@code Enum<? extends Enum<E>}.
* <li>{@code canonicalize(t)} produces a "literal" supertype of t.
* For example: {@code Enum<? extends Enum<?>>} canonicalizes to {@code Enum<?>}, which is
* a supertype (if we disregard the upper bound is implicitly an Enum too).
* <li>If {@code canonicalize(A) == canonicalize(B)}, then {@code Foo<A>.isSubtypeOf(Foo<B>)} and
* vice versa. i.e. {@code A.is(B)} and {@code B.is(A)}.
* <li>{@code canonicalize(canonicalize(A)) == canonicalize(A)}.
* </ol>
*/
private static Type canonicalizeTypeArg(TypeVariable<?> declaration, Type typeArg) {
return typeArg instanceof WildcardType
? canonicalizeWildcardType(declaration, ((WildcardType) typeArg))
: canonicalizeWildcardsInType(typeArg);
}
代码示例来源:origin: google/guava
WildcardType your = canonicalizeWildcardType(declaration, (WildcardType) formalType);
代码示例来源:origin: google/j2objc
WildcardType your = canonicalizeWildcardType(declaration, (WildcardType) formalType);
代码示例来源:origin: wildfly/wildfly
WildcardType your = canonicalizeWildcardType(declaration, (WildcardType) formalType);
代码示例来源:origin: org.jboss.eap/wildfly-client-all
/**
* In reflection, {@code Foo<?>.getUpperBounds()[0]} is always {@code Object.class}, even when Foo
* is defined as {@code Foo<T extends String>}. Thus directly calling {@code <?>.is(String.class)}
* will return false. To mitigate, we canonicalize wildcards by enforcing the following
* invariants:
* <ol>
* <li>{@code canonicalize(t)} always produces the equal result for equivalent types. For example
* both {@code Enum<?>} and {@code Enum<? extends Enum<?>>} canonicalize to
* {@code Enum<? extends Enum<E>}.
* <li>{@code canonicalize(t)} produces a "literal" supertype of t.
* For example: {@code Enum<? extends Enum<?>>} canonicalizes to {@code Enum<?>}, which is
* a supertype (if we disregard the upper bound is implicitly an Enum too).
* <li>If {@code canonicalize(A) == canonicalize(B)}, then {@code Foo<A>.isSubtypeOf(Foo<B>)} and
* vice versa. i.e. {@code A.is(B)} and {@code B.is(A)}.
* <li>{@code canonicalize(canonicalize(A)) == canonicalize(A)}.
* </ol>
*/
private static Type canonicalizeTypeArg(TypeVariable<?> declaration, Type typeArg) {
return typeArg instanceof WildcardType
? canonicalizeWildcardType(declaration, ((WildcardType) typeArg))
: canonicalizeWildcardsInType(typeArg);
}
代码示例来源:origin: org.kill-bill.billing/killbill-platform-osgi-bundles-logger
/**
* In reflection, {@code Foo<?>.getUpperBounds()[0]} is always {@code Object.class}, even when Foo
* is defined as {@code Foo<T extends String>}. Thus directly calling {@code <?>.is(String.class)}
* will return false. To mitigate, we canonicalize wildcards by enforcing the following
* invariants:
* <ol>
* <li>{@code canonicalize(t)} always produces the equal result for equivalent types. For example
* both {@code Enum<?>} and {@code Enum<? extends Enum<?>>} canonicalize to
* {@code Enum<? extends Enum<E>}.
* <li>{@code canonicalize(t)} produces a "literal" supertype of t.
* For example: {@code Enum<? extends Enum<?>>} canonicalizes to {@code Enum<?>}, which is
* a supertype (if we disregard the upper bound is implicitly an Enum too).
* <li>If {@code canonicalize(A) == canonicalize(B)}, then {@code Foo<A>.isSubtypeOf(Foo<B>)} and
* vice versa. i.e. {@code A.is(B)} and {@code B.is(A)}.
* <li>{@code canonicalize(canonicalize(A)) == canonicalize(A)}.
* </ol>
*/
private static Type canonicalizeTypeArg(TypeVariable<?> declaration, Type typeArg) {
return typeArg instanceof WildcardType
? canonicalizeWildcardType(declaration, ((WildcardType) typeArg))
: canonicalizeWildcardsInType(typeArg);
}
代码示例来源:origin: org.jboss.eap/wildfly-client-all
WildcardType your = canonicalizeWildcardType(declaration, (WildcardType) formalType);
代码示例来源:origin: org.kill-bill.billing/killbill-platform-osgi-bundles-logger
WildcardType your = canonicalizeWildcardType(declaration, (WildcardType) formalType);
内容来源于网络,如有侵权,请联系作者删除!