本文整理汇总了Java中com.google.common.reflect.TypeParameter类的典型用法代码示例。如果您正苦于以下问题:Java TypeParameter类的具体用法?Java TypeParameter怎么用?Java TypeParameter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TypeParameter类属于com.google.common.reflect包,在下文中一共展示了TypeParameter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: TypeManifest
import com.google.common.reflect.TypeParameter; //导入依赖的package包/类
public TypeManifest(@Nullable TypeLiteral<T> nullableType) {
this.typeToken = nullableType != null ? Types.toToken(nullableType)
: new TypeToken<T>(getClass()){};
this.type = nullableType != null ? nullableType
: Types.toLiteral(typeToken);
Types.assertFullySpecified(this.type);
this.typeParameter = new TypeParameter<T>(){};
this.typeArg = new TypeArgument<T>(this.type){};
TypeResolver resolver = new TypeResolver();
for(Class<?> cls = getClass(); cls != null; cls = cls.getSuperclass()) {
if(cls.getTypeParameters().length > 0) {
resolver = resolver.where(cls.getTypeParameters()[0], type.getType());
}
}
this.resolver = resolver;
}
示例2: ModelMeta
import com.google.common.reflect.TypeParameter; //导入依赖的package包/类
@Inject ModelMeta(TypeLiteral<M> completeType, TypeLiteral<P> partialType, Provider<Optional<ModelStore<M>>> store) {
this.partialType = Types.toToken(partialType);
this.completeType = Types.toToken(completeType);
partialUpdateType = assertFullySpecified(new TypeToken<PartialModelUpdate<P>>(){}.where(new TypeParameter<P>(){}, this.partialType));
completeUpdateType = assertFullySpecified(new TypeToken<ModelUpdate<M>>(){}.where(new TypeParameter<M>(){}, this.completeType));
multiResponseType = assertFullySpecified(new TypeToken<FindMultiResponse<M>>(){}.where(new TypeParameter<M>(){}, this.completeType));
this.store = store;
final ModelName annot = completeType.getRawType().getAnnotation(ModelName.class);
if(annot != null) {
name = annot.value();
singularName = annot.singular().length() > 0 ? annot.singular() : name.toLowerCase();
pluralName = annot.plural().length() > 0 ? annot.plural() : StringUtils.pluralize(singularName);
} else {
name = completeType.getRawType().getSimpleName();
singularName = name.toLowerCase();
pluralName = StringUtils.pluralize(singularName);
}
}
示例3: checkParameterizedSchema
import com.google.common.reflect.TypeParameter; //导入依赖的package包/类
private <T> void checkParameterizedSchema(Schema schema, Class<T> type) {
assertThat(schema).isEqualTo(Schema.builder()
.setName("Parameterized_" + type.getSimpleName())
.setType("object")
.addField("foo", Field.builder()
.setName("foo")
.setType(FieldType.fromType(TypeToken.of(type)))
.build())
.addField("next", Field.builder()
.setName("next")
.setType(FieldType.OBJECT)
.setSchemaReference(
SchemaReference.create(repo, config, new TypeToken<Parameterized<T>>() {}
.where(new TypeParameter<T>() {}, TypeToken.of(type))))
.build())
.addField("testEnum", Field.builder()
.setName("testEnum")
.setType(FieldType.ENUM)
.setSchemaReference(SchemaReference.create(repo, config, TypeToken.of(TestEnum.class)))
.build())
.build());
}
示例4: DefaultObservableGraph
import com.google.common.reflect.TypeParameter; //导入依赖的package包/类
/**
* @param nodeType The type of values associated with nodes
* @param edgeType The type of value associated with edges
* @param nodeList Creates the list of nodes
* @param edgeList Creates the list of edges
*/
public DefaultObservableGraph(TypeToken<N> nodeType, TypeToken<E> edgeType,
CollectionCreator<Node<N, E>, ObservableList<Node<N, E>>> nodeList,
CollectionCreator<Edge<N, E>, ObservableList<Edge<N, E>>> edgeList) {
theLock = new ReentrantReadWriteLock();
theSessionController = new DefaultTransactable(theLock);
theNodeController = nodeList.create(
new TypeToken<Node<N, E>>() {}.where(new TypeParameter<N>() {}, nodeType).where(new TypeParameter<E>() {}, edgeType), theLock,
theSessionController.getSession(), theSessionController);
theNodes = theNodeController.immutable();
theEdgeController = edgeList.create(
new TypeToken<Edge<N, E>>() {}.where(new TypeParameter<N>() {}, nodeType).where(new TypeParameter<E>() {}, edgeType), theLock,
theSessionController.getSession(), theSessionController);
theEdges = theEdgeController.immutable();
}
示例5: map
import com.google.common.reflect.TypeParameter; //导入依赖的package包/类
public static <K, V> ThriftType map(ThriftTypeReference keyTypeReference,
ThriftTypeReference valueTypeReference)
{
requireNonNull(keyTypeReference, "keyTypeReference is null");
requireNonNull(valueTypeReference, "valueTypeReference is null");
@SuppressWarnings("serial")
Type javaType = new TypeToken<Map<K, V>>() {}
.where(new TypeParameter<K>() {}, (TypeToken<K>) TypeToken.of(keyTypeReference.getJavaType()))
.where(new TypeParameter<V>() {}, (TypeToken<V>) TypeToken.of(valueTypeReference.getJavaType()))
.getType();
return new ThriftType(ThriftProtocolType.MAP, javaType, keyTypeReference, valueTypeReference);
}
示例6: set
import com.google.common.reflect.TypeParameter; //导入依赖的package包/类
public static <E> ThriftType set(ThriftTypeReference valueTypeReference)
{
requireNonNull(valueTypeReference, "valueTypeReference is null");
@SuppressWarnings("serial")
Type javaType = new TypeToken<Set<E>>() {}
.where(new TypeParameter<E>() {}, (TypeToken<E>) TypeToken.of(valueTypeReference.getJavaType()))
.getType();
return new ThriftType(ThriftProtocolType.SET, javaType, null, valueTypeReference);
}
示例7: list
import com.google.common.reflect.TypeParameter; //导入依赖的package包/类
public static <E> ThriftType list(ThriftTypeReference valueTypeReference)
{
requireNonNull(valueTypeReference, "valueTypeReference is null");
@SuppressWarnings("serial")
Type javaType = new TypeToken<List<E>>() {}
.where(new TypeParameter<E>() {}, (TypeToken<E>) TypeToken.of(valueTypeReference.getJavaType()))
.getType();
return new ThriftType(ThriftProtocolType.LIST, javaType, null, valueTypeReference);
}
示例8: driftClientTypeLiteral
import com.google.common.reflect.TypeParameter; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private static <T> TypeLiteral<DriftClient<T>> driftClientTypeLiteral(Class<T> clientInterface)
{
Type javaType = new TypeToken<DriftClient<T>>() {}
.where(new TypeParameter<T>() {}, TypeToken.of(clientInterface))
.getType();
return (TypeLiteral<DriftClient<T>>) TypeLiteral.get(javaType);
}
示例9: getListTokenFromSet
import com.google.common.reflect.TypeParameter; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private <E> TypeToken<List<E>> getListTokenFromSet(TypeToken<?> type) {
// Get the inner type out of the type token
TypeToken<?> innerType = getInnerToken(type);
// Put it into the new list token
return new TypeToken<List<E>>() {}.where(new TypeParameter<E>() {}, (TypeToken<E>)innerType);
}
示例10: listOfElements
import com.google.common.reflect.TypeParameter; //导入依赖的package包/类
private static <T>
TypeToken<List<T>> listOfElements(Class<T> elementType) {
@SuppressWarnings("serial")
TypeToken<List<T>> genericList = new TypeToken<List<T>>() {
// Reifies T
};
return genericList.where(
new TypeParameter<T>() {
// Reifires T
}, elementType);
}
开发者ID:mikesamuel,项目名称:closure-maven-plugin,代码行数:12,代码来源:CheckJsOptionsCompatibleWithCompilerFlagsTest.java
示例11: getMembersInjector
import com.google.common.reflect.TypeParameter; //导入依赖的package包/类
@Override
public <T> MembersInjector<T> getMembersInjector(TypeToken<T> typeLiteral) {
TypeToken<MembersInjector<T>> injectorType = new TypeToken<MembersInjector<T>>() {
private static final long serialVersionUID = 1L;
}.where(new TypeParameter<T>() {
}, typeLiteral);
return getInstance(DependencyKey.of(injectorType));
}
示例12: getMembersInjector
import com.google.common.reflect.TypeParameter; //导入依赖的package包/类
@Override
public <T> MembersInjector<T> getMembersInjector(
TypeLiteral<T> typeLiteral) {
TypeToken<MembersInjector<T>> injectorType = new TypeToken<MembersInjector<T>>() {
private static final long serialVersionUID = 1L;
}.where(new TypeParameter<T>() {
}, typeLiteral.getTypeToken());
return delegate.getInstance(DependencyKey.of(injectorType));
}
示例13: listOf
import com.google.common.reflect.TypeParameter; //导入依赖的package包/类
@SuppressWarnings("serial")
public static <T> TypeToken<List<T>> listOf(final TypeToken<T> entityType) {
final TypeToken<List<T>> listType = new TypeToken<List<T>>() {
// nothing to implement!
};
final TypeParameter<T> elementType = new TypeParameter<T>() {
// nothing to implement!
};
return listType.where(elementType, entityType);
}
示例14: responseEntityOf
import com.google.common.reflect.TypeParameter; //导入依赖的package包/类
public static <T> TypeToken<ResponseEntity<T>> responseEntityOf(final TypeToken<T> entityType) {
final TypeToken<ResponseEntity<T>> responseEntityType = new TypeToken<ResponseEntity<T>>() {
// nothing to implement!
};
final TypeParameter<T> elementType = new TypeParameter<T>() {
// nothing to implement!
};
return responseEntityType.where(elementType, entityType);
}
示例15: streamOf
import com.google.common.reflect.TypeParameter; //导入依赖的package包/类
/**
* Creates specialized stream {@link TypeToken type token} for the given element {@link TypeToken type token}. Used
* to declare the expected stream response {@link TypeToken type token} in Riptide {@link org.zalando.riptide.Route route} as follows:
*
* <pre>
* on(...).call(streamOf(resultTypeToken),...)
* </pre>
*
* @param type element token type.
* @return stream token type.
*/
@SuppressWarnings("serial")
public static <T> TypeToken<Stream<T>> streamOf(final TypeToken<T> type) {
final TypeToken<Stream<T>> streamType = new TypeToken<Stream<T>>() {
// no overriding needed.
};
final TypeParameter<T> elementType = new TypeParameter<T>() {
// no overriding needed.
};
return streamType.where(elementType, type);
}