本文整理了Java中com.google.inject.util.Types.subtypeOf()
方法的一些代码示例,展示了Types.subtypeOf()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Types.subtypeOf()
方法的具体详情如下:
包路径:com.google.inject.util.Types
类名称:Types
方法名:subtypeOf
[英]Returns a type that represents an unknown type that extends bound. For example, if bound is CharSequence.class, this returns ? extends CharSequence. If bound is Object.class, this returns ?, which is shorthand for ? extends Object.
[中]返回表示扩展绑定的未知类型的类型。例如,如果bound是CharSequence。同学们,这个回来了吗?扩展字符序列。如果绑定是对象。同学们,这还回来了吗?,哪个是缩写?扩展对象。
代码示例来源:origin: com.google.inject/guice
Type upperBound = resolveType(originalUpperBound[0]);
if (upperBound != originalUpperBound[0]) {
return Types.subtypeOf(upperBound);
代码示例来源:origin: net.stickycode.bootstrap/sticky-bootstrap-guice4
@SuppressWarnings({ "rawtypes", "unchecked" })
protected void bindParameterizedType(Class<?> annotatedClass, Type type) {
Type wildcard = Types.subtypeOf(Object.class);
Type rawType = ((ParameterizedType) type).getRawType();
Type target = Types.newParameterizedType(rawType, wildcard);
TypeLiteral literal = TypeLiteral.get(target);
debug("multi bind paramterized type {} to {}", literal, annotatedClass);
Multibinder.newSetBinder(binder(), literal).addBinding().to(annotatedClass);
}
代码示例来源:origin: net.stickycode.bootstrap/sticky-bootstrap-guice4
@SuppressWarnings({ "rawtypes", "unchecked" })
protected void bindParameterizedType(Class<?> annotatedClass, Type type) {
Type wildcard = Types.subtypeOf(Object.class);
Type rawType = ((ParameterizedType) type).getRawType();
Type target = Types.newParameterizedType(rawType, wildcard);
TypeLiteral literal = TypeLiteral.get(target);
debug("multi bind paramterized type {} to {}", literal, annotatedClass);
Multibinder.newSetBinder(binder(), literal).addBinding().to(annotatedClass);
}
代码示例来源:origin: net.stickycode.bootstrap/sticky-bootstrap-guice3
@SuppressWarnings({ "rawtypes", "unchecked" })
protected void bindParameterizedType(Class<?> annotatedClass, Type type) {
Type wildcard = Types.subtypeOf(Object.class);
Type rawType = ((ParameterizedType) type).getRawType();
Type target = Types.newParameterizedType(rawType, wildcard);
TypeLiteral literal = TypeLiteral.get(target);
debug("multi bind paramterized type {} to {}", literal, annotatedClass);
Multibinder.newSetBinder(binder(), literal).addBinding().to(annotatedClass);
}
代码示例来源:origin: Nextdoor/bender
Type upperBound = resolveType(originalUpperBound[0]);
if (upperBound != originalUpperBound[0]) {
return Types.subtypeOf(upperBound);
代码示例来源:origin: org.sonatype.sisu/sisu-guice
Type upperBound = resolveType(originalUpperBound[0]);
if (upperBound != originalUpperBound[0]) {
return Types.subtypeOf(upperBound);
代码示例来源:origin: com.jwebmp.inject/guice
Type upperBound = resolveType(originalUpperBound[0]);
if (upperBound != originalUpperBound[0]) {
return Types.subtypeOf(upperBound);
代码示例来源:origin: com.google/inject
Type upperBound = resolveType(originalUpperBound[0]);
if (upperBound != originalUpperBound[0]) {
return Types.subtypeOf(upperBound);
代码示例来源:origin: at.bestsolution.efxclipse.eclipse/com.google.inject
Type upperBound = resolveType(originalUpperBound[0]);
if (upperBound != originalUpperBound[0]) {
return Types.subtypeOf(upperBound);
代码示例来源:origin: org.xbib/guice
Type upperBound = resolveType(originalUpperBound[0]);
if (upperBound != originalUpperBound[0]) {
return Types.subtypeOf(upperBound);
代码示例来源:origin: org.eclipse.sisu/org.eclipse.sisu.inject.tests
assertEquals( getFieldType( "wildcardList" ), types[0] );
assertEquals( types[0], TypeParameters.get( getFieldType( "wildcardListArray" ), 0 ) );
assertEquals( Types.listOf( Types.subtypeOf( Object.class ) ), types[0].getType() );
assertEquals( Types.mapOf( Types.subtypeOf( Object.class ), Types.subtypeOf( Object.class ) ),
types[0].getType() );
assertEquals( getFieldType( "wildcardStringList" ), types[0] );
assertEquals( types[0], TypeParameters.get( getFieldType( "wildcardStringListArray" ), 0 ) );
assertEquals( Types.listOf( Types.subtypeOf( String.class ) ), types[0].getType() );
assertEquals( Types.mapOf( Types.subtypeOf( Float.class ), Types.subtypeOf( Short.class ) ), types[0].getType() );
内容来源于网络,如有侵权,请联系作者删除!