本文整理了Java中com.google.common.reflect.TypeToken.is()
方法的一些代码示例,展示了TypeToken.is()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TypeToken.is()
方法的具体详情如下:
包路径:com.google.common.reflect.TypeToken
类名称:TypeToken
方法名:is
[英]A.is(B) is defined as Foo[.isSubtypeOf(Foo).
Specifically, returns true if any of the following conditions is met:
It appears that properly handling recursive type bounds in the presence of implicit type bounds is not easy. For now we punt, hoping that this defect should rarely cause issues in real code.
](https://www.tabnine.com/code/java/methods/com.google.common.reflect.TypeToken/is#)
[中]A.is(B)被定义为Foo[.isSubtypeOf(Foo).
Specifically, returns true if any of the following conditions is met:
It appears that properly handling recursive type bounds in the presence of implicit type bounds is not easy. For now we punt, hoping that this defect should rarely cause issues in real code.
](https://www.tabnine.com/code/java/methods/com.google.common.reflect.TypeToken/is#)
代码示例来源:origin: google/guava
private boolean isSubtypeOfParameterizedType(ParameterizedType supertype) {
Class<?> matchedClass = of(supertype).getRawType();
if (!someRawTypeIsSubclassOf(matchedClass)) {
return false;
}
TypeVariable<?>[] typeVars = matchedClass.getTypeParameters();
Type[] supertypeArgs = supertype.getActualTypeArguments();
for (int i = 0; i < typeVars.length; i++) {
Type subtypeParam = getCovariantTypeResolver().resolveType(typeVars[i]);
// If 'supertype' is "List<? extends CharSequence>"
// and 'this' is StringArrayList,
// First step is to figure out StringArrayList "is-a" List<E> where <E> = String.
// String is then matched against <? extends CharSequence>, the supertypeArgs[0].
if (!of(subtypeParam).is(supertypeArgs[i], typeVars[i])) {
return false;
}
}
// We only care about the case when the supertype is a non-static inner class
// in which case we need to make sure the subclass's owner type is a subtype of the
// supertype's owner.
return Modifier.isStatic(((Class<?>) supertype.getRawType()).getModifiers())
|| supertype.getOwnerType() == null
|| isOwnedBySubtypeOf(supertype.getOwnerType());
}
代码示例来源:origin: google/j2objc
private boolean isSubtypeOfParameterizedType(ParameterizedType supertype) {
Class<?> matchedClass = of(supertype).getRawType();
if (!someRawTypeIsSubclassOf(matchedClass)) {
return false;
}
TypeVariable<?>[] typeVars = matchedClass.getTypeParameters();
Type[] supertypeArgs = supertype.getActualTypeArguments();
for (int i = 0; i < typeVars.length; i++) {
Type subtypeParam = getCovariantTypeResolver().resolveType(typeVars[i]);
// If 'supertype' is "List<? extends CharSequence>"
// and 'this' is StringArrayList,
// First step is to figure out StringArrayList "is-a" List<E> where <E> = String.
// String is then matched against <? extends CharSequence>, the supertypeArgs[0].
if (!of(subtypeParam).is(supertypeArgs[i], typeVars[i])) {
return false;
}
}
// We only care about the case when the supertype is a non-static inner class
// in which case we need to make sure the subclass's owner type is a subtype of the
// supertype's owner.
return Modifier.isStatic(((Class<?>) supertype.getRawType()).getModifiers())
|| supertype.getOwnerType() == null
|| isOwnedBySubtypeOf(supertype.getOwnerType());
}
代码示例来源:origin: wildfly/wildfly
private boolean isSubtypeOfParameterizedType(ParameterizedType supertype) {
Class<?> matchedClass = of(supertype).getRawType();
if (!someRawTypeIsSubclassOf(matchedClass)) {
return false;
}
TypeVariable<?>[] typeVars = matchedClass.getTypeParameters();
Type[] supertypeArgs = supertype.getActualTypeArguments();
for (int i = 0; i < typeVars.length; i++) {
Type subtypeParam = getCovariantTypeResolver().resolveType(typeVars[i]);
// If 'supertype' is "List<? extends CharSequence>"
// and 'this' is StringArrayList,
// First step is to figure out StringArrayList "is-a" List<E> where <E> = String.
// String is then matched against <? extends CharSequence>, the supertypeArgs[0].
if (!of(subtypeParam).is(supertypeArgs[i], typeVars[i])) {
return false;
}
}
// We only care about the case when the supertype is a non-static inner class
// in which case we need to make sure the subclass's owner type is a subtype of the
// supertype's owner.
return Modifier.isStatic(((Class<?>) supertype.getRawType()).getModifiers())
|| supertype.getOwnerType() == null
|| isOwnedBySubtypeOf(supertype.getOwnerType());
}
代码示例来源:origin: org.jboss.eap/wildfly-client-all
private boolean isSubtypeOfParameterizedType(ParameterizedType supertype) {
Class<?> matchedClass = of(supertype).getRawType();
if (!someRawTypeIsSubclassOf(matchedClass)) {
return false;
}
TypeVariable<?>[] typeVars = matchedClass.getTypeParameters();
Type[] supertypeArgs = supertype.getActualTypeArguments();
for (int i = 0; i < typeVars.length; i++) {
Type subtypeParam = getCovariantTypeResolver().resolveType(typeVars[i]);
// If 'supertype' is "List<? extends CharSequence>"
// and 'this' is StringArrayList,
// First step is to figure out StringArrayList "is-a" List<E> where <E> = String.
// String is then matched against <? extends CharSequence>, the supertypeArgs[0].
if (!of(subtypeParam).is(supertypeArgs[i], typeVars[i])) {
return false;
}
}
// We only care about the case when the supertype is a non-static inner class
// in which case we need to make sure the subclass's owner type is a subtype of the
// supertype's owner.
return Modifier.isStatic(((Class<?>) supertype.getRawType()).getModifiers())
|| supertype.getOwnerType() == null
|| isOwnedBySubtypeOf(supertype.getOwnerType());
}
代码示例来源:origin: org.kill-bill.billing/killbill-platform-osgi-bundles-logger
private boolean isSubtypeOfParameterizedType(ParameterizedType supertype) {
Class<?> matchedClass = of(supertype).getRawType();
if (!someRawTypeIsSubclassOf(matchedClass)) {
return false;
}
TypeVariable<?>[] typeVars = matchedClass.getTypeParameters();
Type[] supertypeArgs = supertype.getActualTypeArguments();
for (int i = 0; i < typeVars.length; i++) {
Type subtypeParam = getCovariantTypeResolver().resolveType(typeVars[i]);
// If 'supertype' is "List<? extends CharSequence>"
// and 'this' is StringArrayList,
// First step is to figure out StringArrayList "is-a" List<E> where <E> = String.
// String is then matched against <? extends CharSequence>, the supertypeArgs[0].
if (!of(subtypeParam).is(supertypeArgs[i], typeVars[i])) {
return false;
}
}
// We only care about the case when the supertype is a non-static inner class
// in which case we need to make sure the subclass's owner type is a subtype of the
// supertype's owner.
return Modifier.isStatic(((Class<?>) supertype.getRawType()).getModifiers())
|| supertype.getOwnerType() == null
|| isOwnedBySubtypeOf(supertype.getOwnerType());
}
内容来源于网络,如有侵权,请联系作者删除!