本文整理了Java中com.google.common.reflect.TypeToken.canonicalizeWildcardsInType()
方法的一些代码示例,展示了TypeToken.canonicalizeWildcardsInType()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TypeToken.canonicalizeWildcardsInType()
方法的具体详情如下:
包路径:com.google.common.reflect.TypeToken
类名称:TypeToken
方法名:canonicalizeWildcardsInType
暂无
代码示例来源: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/guava
private static WildcardType canonicalizeWildcardType(
TypeVariable<?> declaration, WildcardType type) {
Type[] declared = declaration.getBounds();
List<Type> upperBounds = new ArrayList<>();
for (Type bound : type.getUpperBounds()) {
if (!any(declared).isSubtypeOf(bound)) {
upperBounds.add(canonicalizeWildcardsInType(bound));
}
}
return new Types.WildcardTypeImpl(type.getLowerBounds(), upperBounds.toArray(new Type[0]));
}
代码示例来源:origin: google/guava
private static Type canonicalizeWildcardsInType(Type type) {
if (type instanceof ParameterizedType) {
return canonicalizeWildcardsInParameterizedType((ParameterizedType) type);
}
if (type instanceof GenericArrayType) {
return Types.newArrayType(
canonicalizeWildcardsInType(((GenericArrayType) type).getGenericComponentType()));
}
return type;
}
代码示例来源:origin: google/j2objc
private static WildcardType canonicalizeWildcardType(
TypeVariable<?> declaration, WildcardType type) {
Type[] declared = declaration.getBounds();
List<Type> upperBounds = new ArrayList<>();
for (Type bound : type.getUpperBounds()) {
if (!any(declared).isSubtypeOf(bound)) {
upperBounds.add(canonicalizeWildcardsInType(bound));
}
}
return new Types.WildcardTypeImpl(type.getLowerBounds(), upperBounds.toArray(new Type[0]));
}
代码示例来源:origin: wildfly/wildfly
private static WildcardType canonicalizeWildcardType(
TypeVariable<?> declaration, WildcardType type) {
Type[] declared = declaration.getBounds();
List<Type> upperBounds = new ArrayList<>();
for (Type bound : type.getUpperBounds()) {
if (!any(declared).isSubtypeOf(bound)) {
upperBounds.add(canonicalizeWildcardsInType(bound));
}
}
return new Types.WildcardTypeImpl(type.getLowerBounds(), upperBounds.toArray(new Type[0]));
}
代码示例来源: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: google/j2objc
private static Type canonicalizeWildcardsInType(Type type) {
if (type instanceof ParameterizedType) {
return canonicalizeWildcardsInParameterizedType((ParameterizedType) type);
}
if (type instanceof GenericArrayType) {
return Types.newArrayType(
canonicalizeWildcardsInType(((GenericArrayType) type).getGenericComponentType()));
}
return type;
}
代码示例来源:origin: google/guava
&& every(your.getLowerBounds()).isSubtypeOf(runtimeType);
return canonicalizeWildcardsInType(runtimeType)
.equals(canonicalizeWildcardsInType(formalType));
代码示例来源:origin: wildfly/wildfly
private static Type canonicalizeWildcardsInType(Type type) {
if (type instanceof ParameterizedType) {
return canonicalizeWildcardsInParameterizedType((ParameterizedType) type);
}
if (type instanceof GenericArrayType) {
return Types.newArrayType(
canonicalizeWildcardsInType(((GenericArrayType) type).getGenericComponentType()));
}
return type;
}
代码示例来源: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/j2objc
&& every(your.getLowerBounds()).isSubtypeOf(runtimeType);
return canonicalizeWildcardsInType(runtimeType)
.equals(canonicalizeWildcardsInType(formalType));
代码示例来源:origin: wildfly/wildfly
&& every(your.getLowerBounds()).isSubtypeOf(runtimeType);
return canonicalizeWildcardsInType(runtimeType)
.equals(canonicalizeWildcardsInType(formalType));
代码示例来源:origin: org.jboss.eap/wildfly-client-all
private static Type canonicalizeWildcardsInType(Type type) {
if (type instanceof ParameterizedType) {
return canonicalizeWildcardsInParameterizedType((ParameterizedType) type);
}
if (type instanceof GenericArrayType) {
return Types.newArrayType(
canonicalizeWildcardsInType(((GenericArrayType) type).getGenericComponentType()));
}
return type;
}
代码示例来源: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.jboss.eap/wildfly-client-all
private static WildcardType canonicalizeWildcardType(
TypeVariable<?> declaration, WildcardType type) {
Type[] declared = declaration.getBounds();
List<Type> upperBounds = new ArrayList<>();
for (Type bound : type.getUpperBounds()) {
if (!any(declared).isSubtypeOf(bound)) {
upperBounds.add(canonicalizeWildcardsInType(bound));
}
}
return new Types.WildcardTypeImpl(type.getLowerBounds(), upperBounds.toArray(new Type[0]));
}
代码示例来源:origin: org.kill-bill.billing/killbill-platform-osgi-bundles-logger
private static WildcardType canonicalizeWildcardType(
TypeVariable<?> declaration, WildcardType type) {
Type[] declared = declaration.getBounds();
List<Type> upperBounds = new ArrayList<>();
for (Type bound : type.getUpperBounds()) {
if (!any(declared).isSubtypeOf(bound)) {
upperBounds.add(canonicalizeWildcardsInType(bound));
}
}
return new Types.WildcardTypeImpl(type.getLowerBounds(), upperBounds.toArray(new Type[0]));
}
代码示例来源:origin: org.kill-bill.billing/killbill-platform-osgi-bundles-logger
private static Type canonicalizeWildcardsInType(Type type) {
if (type instanceof ParameterizedType) {
return canonicalizeWildcardsInParameterizedType((ParameterizedType) type);
}
if (type instanceof GenericArrayType) {
return Types.newArrayType(
canonicalizeWildcardsInType(((GenericArrayType) type).getGenericComponentType()));
}
return type;
}
代码示例来源: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
&& every(your.getLowerBounds()).isSubtypeOf(runtimeType);
return canonicalizeWildcardsInType(runtimeType)
.equals(canonicalizeWildcardsInType(formalType));
代码示例来源:origin: org.kill-bill.billing/killbill-platform-osgi-bundles-logger
&& every(your.getLowerBounds()).isSubtypeOf(runtimeType);
return canonicalizeWildcardsInType(runtimeType)
.equals(canonicalizeWildcardsInType(formalType));
内容来源于网络,如有侵权,请联系作者删除!