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

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

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

TypeToken.boundsAsInterfaces介绍

暂无

代码示例

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

/**
 * Returns the generic interfaces that this type directly {@code implements}. This method is
 * similar but different from {@link Class#getGenericInterfaces()}. For example, {@code new
 * TypeToken<List<String>>() {}.getGenericInterfaces()} will return a list that contains {@code
 * new TypeToken<Iterable<String>>() {}}; while {@code List.class.getGenericInterfaces()} will
 * return an array that contains {@code Iterable<T>}, where the {@code T} is the type variable
 * declared by interface {@code Iterable}.
 *
 * <p>If this type is a type variable or wildcard, its upper bounds are examined and those that
 * are either an interface or upper-bounded only by interfaces are returned. This means that the
 * returned types could include type variables too.
 */
final ImmutableList<TypeToken<? super T>> getGenericInterfaces() {
 if (runtimeType instanceof TypeVariable) {
  return boundsAsInterfaces(((TypeVariable<?>) runtimeType).getBounds());
 }
 if (runtimeType instanceof WildcardType) {
  return boundsAsInterfaces(((WildcardType) runtimeType).getUpperBounds());
 }
 ImmutableList.Builder<TypeToken<? super T>> builder = ImmutableList.builder();
 for (Type interfaceType : getRawType().getGenericInterfaces()) {
  @SuppressWarnings("unchecked") // interface of T
  TypeToken<? super T> resolvedInterface =
    (TypeToken<? super T>) resolveSupertype(interfaceType);
  builder.add(resolvedInterface);
 }
 return builder.build();
}

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

/**
 * Returns the generic interfaces that this type directly {@code implements}. This method is
 * similar but different from {@link Class#getGenericInterfaces()}. For example, {@code new
 * TypeToken<List<String>>() {}.getGenericInterfaces()} will return a list that contains {@code
 * new TypeToken<Iterable<String>>() {}}; while {@code List.class.getGenericInterfaces()} will
 * return an array that contains {@code Iterable<T>}, where the {@code T} is the type variable
 * declared by interface {@code Iterable}.
 *
 * <p>If this type is a type variable or wildcard, its upper bounds are examined and those that
 * are either an interface or upper-bounded only by interfaces are returned. This means that the
 * returned types could include type variables too.
 */
final ImmutableList<TypeToken<? super T>> getGenericInterfaces() {
 if (runtimeType instanceof TypeVariable) {
  return boundsAsInterfaces(((TypeVariable<?>) runtimeType).getBounds());
 }
 if (runtimeType instanceof WildcardType) {
  return boundsAsInterfaces(((WildcardType) runtimeType).getUpperBounds());
 }
 ImmutableList.Builder<TypeToken<? super T>> builder = ImmutableList.builder();
 for (Type interfaceType : getRawType().getGenericInterfaces()) {
  @SuppressWarnings("unchecked") // interface of T
  TypeToken<? super T> resolvedInterface =
    (TypeToken<? super T>) resolveSupertype(interfaceType);
  builder.add(resolvedInterface);
 }
 return builder.build();
}

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

/**
 * Returns the generic interfaces that this type directly {@code implements}. This method is
 * similar but different from {@link Class#getGenericInterfaces()}. For example, {@code new
 * TypeToken<List<String>>() {}.getGenericInterfaces()} will return a list that contains {@code
 * new TypeToken<Iterable<String>>() {}}; while {@code List.class.getGenericInterfaces()} will
 * return an array that contains {@code Iterable<T>}, where the {@code T} is the type variable
 * declared by interface {@code Iterable}.
 *
 * <p>If this type is a type variable or wildcard, its upper bounds are examined and those that
 * are either an interface or upper-bounded only by interfaces are returned. This means that the
 * returned types could include type variables too.
 */
final ImmutableList<TypeToken<? super T>> getGenericInterfaces() {
 if (runtimeType instanceof TypeVariable) {
  return boundsAsInterfaces(((TypeVariable<?>) runtimeType).getBounds());
 }
 if (runtimeType instanceof WildcardType) {
  return boundsAsInterfaces(((WildcardType) runtimeType).getUpperBounds());
 }
 ImmutableList.Builder<TypeToken<? super T>> builder = ImmutableList.builder();
 for (Type interfaceType : getRawType().getGenericInterfaces()) {
  @SuppressWarnings("unchecked") // interface of T
  TypeToken<? super T> resolvedInterface =
    (TypeToken<? super T>) resolveSupertype(interfaceType);
  builder.add(resolvedInterface);
 }
 return builder.build();
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

/**
 * Returns the generic interfaces that this type directly {@code implements}. This method is
 * similar but different from {@link Class#getGenericInterfaces()}. For example, {@code
 * new TypeToken<List<String>>() {}.getGenericInterfaces()} will return a list that contains
 * {@code new TypeToken<Iterable<String>>() {}}; while {@code List.class.getGenericInterfaces()}
 * will return an array that contains {@code Iterable<T>}, where the {@code T} is the type
 * variable declared by interface {@code Iterable}.
 *
 * <p>If this type is a type variable or wildcard, its upper bounds are examined and those that
 * are either an interface or upper-bounded only by interfaces are returned. This means that the
 * returned types could include type variables too.
 */
final ImmutableList<TypeToken<? super T>> getGenericInterfaces() {
 if (runtimeType instanceof TypeVariable) {
  return boundsAsInterfaces(((TypeVariable<?>) runtimeType).getBounds());
 }
 if (runtimeType instanceof WildcardType) {
  return boundsAsInterfaces(((WildcardType) runtimeType).getUpperBounds());
 }
 ImmutableList.Builder<TypeToken<? super T>> builder = ImmutableList.builder();
 for (Type interfaceType : getRawType().getGenericInterfaces()) {
  @SuppressWarnings("unchecked") // interface of T
  TypeToken<? super T> resolvedInterface = (TypeToken<? super T>)
    resolveSupertype(interfaceType);
  builder.add(resolvedInterface);
 }
 return builder.build();
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics

/**
 * Returns the generic interfaces that this type directly {@code implements}. This method is
 * similar but different from {@link Class#getGenericInterfaces()}. For example, {@code
 * new TypeToken<List<String>>() {}.getGenericInterfaces()} will return a list that contains
 * {@code new TypeToken<Iterable<String>>() {}}; while {@code List.class.getGenericInterfaces()}
 * will return an array that contains {@code Iterable<T>}, where the {@code T} is the type
 * variable declared by interface {@code Iterable}.
 *
 * <p>If this type is a type variable or wildcard, its upper bounds are examined and those that
 * are either an interface or upper-bounded only by interfaces are returned. This means that the
 * returned types could include type variables too.
 */
final ImmutableList<TypeToken<? super T>> getGenericInterfaces() {
 if (runtimeType instanceof TypeVariable) {
  return boundsAsInterfaces(((TypeVariable<?>) runtimeType).getBounds());
 }
 if (runtimeType instanceof WildcardType) {
  return boundsAsInterfaces(((WildcardType) runtimeType).getUpperBounds());
 }
 ImmutableList.Builder<TypeToken<? super T>> builder = ImmutableList.builder();
 for (Type interfaceType : getRawType().getGenericInterfaces()) {
  @SuppressWarnings("unchecked") // interface of T
  TypeToken<? super T> resolvedInterface = (TypeToken<? super T>)
    resolveSupertype(interfaceType);
  builder.add(resolvedInterface);
 }
 return builder.build();
}

代码示例来源:origin: org.hudsonci.lib.guava/guava

/**
 * Returns the generic interfaces that this type directly {@code implements}. This method is
 * similar but different from {@link Class#getGenericInterfaces()}. For example, {@code
 * new TypeToken<List<String>>() {}.getGenericInterfaces()} will return a list that contains
 * {@code new TypeToken<Iterable<String>>() {}}; while {@code List.class.getGenericInterfaces()}
 * will return an array that contains {@code Iterable<T>}, where the {@code T} is the type
 * variable declared by interface {@code Iterable}.
 *
 * <p>If this type is a type variable or wildcard, its upper bounds are examined and those that
 * are either an interface or upper-bounded only by interfaces are returned. This means that the
 * returned types could include type variables too.
 */
final ImmutableList<TypeToken<? super T>> getGenericInterfaces() {
 if (runtimeType instanceof TypeVariable) {
  return boundsAsInterfaces(((TypeVariable<?>) runtimeType).getBounds());
 }
 if (runtimeType instanceof WildcardType) {
  return boundsAsInterfaces(((WildcardType) runtimeType).getUpperBounds());
 }
 ImmutableList.Builder<TypeToken<? super T>> builder = ImmutableList.builder();
 for (Type interfaceType : getRawType().getGenericInterfaces()) {
  @SuppressWarnings("unchecked") // interface of T
  TypeToken<? super T> resolvedInterface = (TypeToken<? super T>)
    resolveSupertype(interfaceType);
  builder.add(resolvedInterface);
 }
 return builder.build();
}

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

/**
 * Returns the generic interfaces that this type directly {@code implements}. This method is
 * similar but different from {@link Class#getGenericInterfaces()}. For example, {@code
 * new TypeToken<List<String>>() {}.getGenericInterfaces()} will return a list that contains
 * {@code new TypeToken<Iterable<String>>() {}}; while {@code List.class.getGenericInterfaces()}
 * will return an array that contains {@code Iterable<T>}, where the {@code T} is the type
 * variable declared by interface {@code Iterable}.
 *
 * <p>If this type is a type variable or wildcard, its upper bounds are examined and those that
 * are either an interface or upper-bounded only by interfaces are returned. This means that the
 * returned types could include type variables too.
 */
final ImmutableList<TypeToken<? super T>> getGenericInterfaces() {
 if (runtimeType instanceof TypeVariable) {
  return boundsAsInterfaces(((TypeVariable<?>) runtimeType).getBounds());
 }
 if (runtimeType instanceof WildcardType) {
  return boundsAsInterfaces(((WildcardType) runtimeType).getUpperBounds());
 }
 ImmutableList.Builder<TypeToken<? super T>> builder = ImmutableList.builder();
 for (Type interfaceType : getRawType().getGenericInterfaces()) {
  @SuppressWarnings("unchecked") // interface of T
  TypeToken<? super T> resolvedInterface = (TypeToken<? super T>)
    resolveSupertype(interfaceType);
  builder.add(resolvedInterface);
 }
 return builder.build();
}

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

/**
 * Returns the generic interfaces that this type directly {@code implements}. This method is
 * similar but different from {@link Class#getGenericInterfaces()}. For example, {@code new
 * TypeToken<List<String>>() {}.getGenericInterfaces()} will return a list that contains {@code
 * new TypeToken<Iterable<String>>() {}}; while {@code List.class.getGenericInterfaces()} will
 * return an array that contains {@code Iterable<T>}, where the {@code T} is the type variable
 * declared by interface {@code Iterable}.
 *
 * <p>If this type is a type variable or wildcard, its upper bounds are examined and those that
 * are either an interface or upper-bounded only by interfaces are returned. This means that the
 * returned types could include type variables too.
 */
final ImmutableList<TypeToken<? super T>> getGenericInterfaces() {
 if (runtimeType instanceof TypeVariable) {
  return boundsAsInterfaces(((TypeVariable<?>) runtimeType).getBounds());
 }
 if (runtimeType instanceof WildcardType) {
  return boundsAsInterfaces(((WildcardType) runtimeType).getUpperBounds());
 }
 ImmutableList.Builder<TypeToken<? super T>> builder = ImmutableList.builder();
 for (Type interfaceType : getRawType().getGenericInterfaces()) {
  @SuppressWarnings("unchecked") // interface of T
  TypeToken<? super T> resolvedInterface =
    (TypeToken<? super T>) resolveSupertype(interfaceType);
  builder.add(resolvedInterface);
 }
 return builder.build();
}

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

/**
 * Returns the generic interfaces that this type directly {@code implements}. This method is
 * similar but different from {@link Class#getGenericInterfaces()}. For example, {@code new
 * TypeToken<List<String>>() {}.getGenericInterfaces()} will return a list that contains {@code
 * new TypeToken<Iterable<String>>() {}}; while {@code List.class.getGenericInterfaces()} will
 * return an array that contains {@code Iterable<T>}, where the {@code T} is the type variable
 * declared by interface {@code Iterable}.
 *
 * <p>If this type is a type variable or wildcard, its upper bounds are examined and those that
 * are either an interface or upper-bounded only by interfaces are returned. This means that the
 * returned types could include type variables too.
 */
final ImmutableList<TypeToken<? super T>> getGenericInterfaces() {
 if (runtimeType instanceof TypeVariable) {
  return boundsAsInterfaces(((TypeVariable<?>) runtimeType).getBounds());
 }
 if (runtimeType instanceof WildcardType) {
  return boundsAsInterfaces(((WildcardType) runtimeType).getUpperBounds());
 }
 ImmutableList.Builder<TypeToken<? super T>> builder = ImmutableList.builder();
 for (Type interfaceType : getRawType().getGenericInterfaces()) {
  @SuppressWarnings("unchecked") // interface of T
  TypeToken<? super T> resolvedInterface =
    (TypeToken<? super T>) resolveSupertype(interfaceType);
  builder.add(resolvedInterface);
 }
 return builder.build();
}

代码示例来源:origin: com.google.guava/guava-jdk5

/**
 * Returns the generic interfaces that this type directly {@code implements}. This method is
 * similar but different from {@link Class#getGenericInterfaces()}. For example, {@code
 * new TypeToken<List<String>>() {}.getGenericInterfaces()} will return a list that contains
 * {@code new TypeToken<Iterable<String>>() {}}; while {@code List.class.getGenericInterfaces()}
 * will return an array that contains {@code Iterable<T>}, where the {@code T} is the type
 * variable declared by interface {@code Iterable}.
 *
 * <p>If this type is a type variable or wildcard, its upper bounds are examined and those that
 * are either an interface or upper-bounded only by interfaces are returned. This means that the
 * returned types could include type variables too.
 */
final ImmutableList<TypeToken<? super T>> getGenericInterfaces() {
 if (runtimeType instanceof TypeVariable) {
  return boundsAsInterfaces(((TypeVariable<?>) runtimeType).getBounds());
 }
 if (runtimeType instanceof WildcardType) {
  return boundsAsInterfaces(((WildcardType) runtimeType).getUpperBounds());
 }
 ImmutableList.Builder<TypeToken<? super T>> builder = ImmutableList.builder();
 for (Type interfaceType : getRawType().getGenericInterfaces()) {
  @SuppressWarnings("unchecked") // interface of T
  TypeToken<? super T> resolvedInterface = (TypeToken<? super T>)
    resolveSupertype(interfaceType);
  builder.add(resolvedInterface);
 }
 return builder.build();
}

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/com.google.guava

/**
 * Returns the generic interfaces that this type directly {@code implements}. This method is
 * similar but different from {@link Class#getGenericInterfaces()}. For example, {@code
 * new TypeToken<List<String>>() {}.getGenericInterfaces()} will return a list that contains
 * {@code new TypeToken<Iterable<String>>() {}}; while {@code List.class.getGenericInterfaces()}
 * will return an array that contains {@code Iterable<T>}, where the {@code T} is the type
 * variable declared by interface {@code Iterable}.
 *
 * <p>If this type is a type variable or wildcard, its upper bounds are examined and those that
 * are either an interface or upper-bounded only by interfaces are returned. This means that the
 * returned types could include type variables too.
 */
final ImmutableList<TypeToken<? super T>> getGenericInterfaces() {
 if (runtimeType instanceof TypeVariable) {
  return boundsAsInterfaces(((TypeVariable<?>) runtimeType).getBounds());
 }
 if (runtimeType instanceof WildcardType) {
  return boundsAsInterfaces(((WildcardType) runtimeType).getUpperBounds());
 }
 ImmutableList.Builder<TypeToken<? super T>> builder = ImmutableList.builder();
 for (Type interfaceType : getRawType().getGenericInterfaces()) {
  @SuppressWarnings("unchecked") // interface of T
  TypeToken<? super T> resolvedInterface = (TypeToken<? super T>)
    resolveSupertype(interfaceType);
  builder.add(resolvedInterface);
 }
 return builder.build();
}

代码示例来源:origin: Nextdoor/bender

/**
 * Returns the generic interfaces that this type directly {@code implements}. This method is
 * similar but different from {@link Class#getGenericInterfaces()}. For example, {@code
 * new TypeToken<List<String>>() {}.getGenericInterfaces()} will return a list that contains
 * {@code new TypeToken<Iterable<String>>() {}}; while {@code List.class.getGenericInterfaces()}
 * will return an array that contains {@code Iterable<T>}, where the {@code T} is the type
 * variable declared by interface {@code Iterable}.
 *
 * <p>If this type is a type variable or wildcard, its upper bounds are examined and those that
 * are either an interface or upper-bounded only by interfaces are returned. This means that the
 * returned types could include type variables too.
 */
final ImmutableList<TypeToken<? super T>> getGenericInterfaces() {
 if (runtimeType instanceof TypeVariable) {
  return boundsAsInterfaces(((TypeVariable<?>) runtimeType).getBounds());
 }
 if (runtimeType instanceof WildcardType) {
  return boundsAsInterfaces(((WildcardType) runtimeType).getUpperBounds());
 }
 ImmutableList.Builder<TypeToken<? super T>> builder = ImmutableList.builder();
 for (Type interfaceType : getRawType().getGenericInterfaces()) {
  @SuppressWarnings("unchecked") // interface of T
  TypeToken<? super T> resolvedInterface = (TypeToken<? super T>)
    resolveSupertype(interfaceType);
  builder.add(resolvedInterface);
 }
 return builder.build();
}

相关文章

微信公众号

最新文章

更多

TypeToken类方法