com.google.common.reflect.TypeToken.someRawTypeIsSubclassOf()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(12.1k)|赞(0)|评价(0)|浏览(102)

本文整理了Java中com.google.common.reflect.TypeToken.someRawTypeIsSubclassOf()方法的一些代码示例,展示了TypeToken.someRawTypeIsSubclassOf()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TypeToken.someRawTypeIsSubclassOf()方法的具体详情如下:
包路径:com.google.common.reflect.TypeToken
类名称:TypeToken
方法名:someRawTypeIsSubclassOf

TypeToken.someRawTypeIsSubclassOf介绍

暂无

代码示例

代码示例来源:origin: google/guava

this.someRawTypeIsSubclassOf(method.getDeclaringClass()),
"%s not declared by %s",
method,

代码示例来源:origin: google/j2objc

this.someRawTypeIsSubclassOf(method.getDeclaringClass()),
"%s not declared by %s",
method,

代码示例来源: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: wildfly/wildfly

this.someRawTypeIsSubclassOf(method.getDeclaringClass()),
"%s not declared by %s",
method,

代码示例来源:origin: google/guava

/**
 * Returns the generic form of {@code superclass}. For example, if this is {@code
 * ArrayList<String>}, {@code Iterable<String>} is returned given the input {@code
 * Iterable.class}.
 */
public final TypeToken<? super T> getSupertype(Class<? super T> superclass) {
 checkArgument(
   this.someRawTypeIsSubclassOf(superclass),
   "%s is not a super class of %s",
   superclass,
   this);
 if (runtimeType instanceof TypeVariable) {
  return getSupertypeFromUpperBounds(superclass, ((TypeVariable<?>) runtimeType).getBounds());
 }
 if (runtimeType instanceof WildcardType) {
  return getSupertypeFromUpperBounds(superclass, ((WildcardType) runtimeType).getUpperBounds());
 }
 if (superclass.isArray()) {
  return getArraySupertype(superclass);
 }
 @SuppressWarnings("unchecked") // resolved supertype
 TypeToken<? super T> supertype =
   (TypeToken<? super T>) resolveSupertype(toGenericType(superclass).runtimeType);
 return supertype;
}

代码示例来源: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: google/guava

return this.someRawTypeIsSubclassOf((Class<?>) supertype);
} else if (supertype instanceof ParameterizedType) {
 return this.isSubtypeOfParameterizedType((ParameterizedType) supertype);

代码示例来源:origin: google/j2objc

/**
 * Returns the generic form of {@code superclass}. For example, if this is {@code
 * ArrayList<String>}, {@code Iterable<String>} is returned given the input {@code
 * Iterable.class}.
 */
public final TypeToken<? super T> getSupertype(Class<? super T> superclass) {
 checkArgument(
   this.someRawTypeIsSubclassOf(superclass),
   "%s is not a super class of %s",
   superclass,
   this);
 if (runtimeType instanceof TypeVariable) {
  return getSupertypeFromUpperBounds(superclass, ((TypeVariable<?>) runtimeType).getBounds());
 }
 if (runtimeType instanceof WildcardType) {
  return getSupertypeFromUpperBounds(superclass, ((WildcardType) runtimeType).getUpperBounds());
 }
 if (superclass.isArray()) {
  return getArraySupertype(superclass);
 }
 @SuppressWarnings("unchecked") // resolved supertype
 TypeToken<? super T> supertype =
   (TypeToken<? super T>) resolveSupertype(toGenericType(superclass).runtimeType);
 return supertype;
}

代码示例来源:origin: wildfly/wildfly

/**
 * Returns the generic form of {@code superclass}. For example, if this is {@code
 * ArrayList<String>}, {@code Iterable<String>} is returned given the input {@code
 * Iterable.class}.
 */
public final TypeToken<? super T> getSupertype(Class<? super T> superclass) {
 checkArgument(
   this.someRawTypeIsSubclassOf(superclass),
   "%s is not a super class of %s",
   superclass,
   this);
 if (runtimeType instanceof TypeVariable) {
  return getSupertypeFromUpperBounds(superclass, ((TypeVariable<?>) runtimeType).getBounds());
 }
 if (runtimeType instanceof WildcardType) {
  return getSupertypeFromUpperBounds(superclass, ((WildcardType) runtimeType).getUpperBounds());
 }
 if (superclass.isArray()) {
  return getArraySupertype(superclass);
 }
 @SuppressWarnings("unchecked") // resolved supertype
 TypeToken<? super T> supertype =
   (TypeToken<? super T>) resolveSupertype(toGenericType(superclass).runtimeType);
 return supertype;
}

代码示例来源:origin: google/j2objc

return this.someRawTypeIsSubclassOf((Class<?>) supertype);
} else if (supertype instanceof ParameterizedType) {
 return this.isSubtypeOfParameterizedType((ParameterizedType) supertype);

代码示例来源:origin: wildfly/wildfly

return this.someRawTypeIsSubclassOf((Class<?>) supertype);
} else if (supertype instanceof ParameterizedType) {
 return this.isSubtypeOfParameterizedType((ParameterizedType) supertype);

代码示例来源:origin: org.kill-bill.billing/killbill-platform-osgi-bundles-logger

this.someRawTypeIsSubclassOf(method.getDeclaringClass()),
"%s not declared by %s",
method,

代码示例来源:origin: org.jboss.eap/wildfly-client-all

this.someRawTypeIsSubclassOf(method.getDeclaringClass()),
"%s not declared by %s",
method,

代码示例来源: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());
}

代码示例来源: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.jboss.eap/wildfly-client-all

/**
 * Returns the generic form of {@code superclass}. For example, if this is {@code
 * ArrayList<String>}, {@code Iterable<String>} is returned given the input {@code
 * Iterable.class}.
 */
public final TypeToken<? super T> getSupertype(Class<? super T> superclass) {
 checkArgument(
   this.someRawTypeIsSubclassOf(superclass),
   "%s is not a super class of %s",
   superclass,
   this);
 if (runtimeType instanceof TypeVariable) {
  return getSupertypeFromUpperBounds(superclass, ((TypeVariable<?>) runtimeType).getBounds());
 }
 if (runtimeType instanceof WildcardType) {
  return getSupertypeFromUpperBounds(superclass, ((WildcardType) runtimeType).getUpperBounds());
 }
 if (superclass.isArray()) {
  return getArraySupertype(superclass);
 }
 @SuppressWarnings("unchecked") // resolved supertype
 TypeToken<? super T> supertype =
   (TypeToken<? super T>) resolveSupertype(toGenericType(superclass).runtimeType);
 return supertype;
}

代码示例来源:origin: org.kill-bill.billing/killbill-platform-osgi-bundles-logger

/**
 * Returns the generic form of {@code superclass}. For example, if this is {@code
 * ArrayList<String>}, {@code Iterable<String>} is returned given the input {@code
 * Iterable.class}.
 */
public final TypeToken<? super T> getSupertype(Class<? super T> superclass) {
 checkArgument(
   this.someRawTypeIsSubclassOf(superclass),
   "%s is not a super class of %s",
   superclass,
   this);
 if (runtimeType instanceof TypeVariable) {
  return getSupertypeFromUpperBounds(superclass, ((TypeVariable<?>) runtimeType).getBounds());
 }
 if (runtimeType instanceof WildcardType) {
  return getSupertypeFromUpperBounds(superclass, ((WildcardType) runtimeType).getUpperBounds());
 }
 if (superclass.isArray()) {
  return getArraySupertype(superclass);
 }
 @SuppressWarnings("unchecked") // resolved supertype
 TypeToken<? super T> supertype =
   (TypeToken<? super T>) resolveSupertype(toGenericType(superclass).runtimeType);
 return supertype;
}

代码示例来源:origin: org.kill-bill.billing/killbill-platform-osgi-bundles-logger

return this.someRawTypeIsSubclassOf((Class<?>) supertype);
} else if (supertype instanceof ParameterizedType) {
 return this.isSubtypeOfParameterizedType((ParameterizedType) supertype);

代码示例来源:origin: org.jboss.eap/wildfly-client-all

return this.someRawTypeIsSubclassOf((Class<?>) supertype);
} else if (supertype instanceof ParameterizedType) {
 return this.isSubtypeOfParameterizedType((ParameterizedType) supertype);

相关文章

微信公众号

最新文章

更多

TypeToken类方法