本文整理汇总了Java中com.google.inject.TypeLiteral.get方法的典型用法代码示例。如果您正苦于以下问题:Java TypeLiteral.get方法的具体用法?Java TypeLiteral.get怎么用?Java TypeLiteral.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.inject.TypeLiteral
的用法示例。
在下文中一共展示了TypeLiteral.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: bindNumber
import com.google.inject.TypeLiteral; //导入方法依赖的package包/类
private <T extends Number & Comparable<T>> void bindNumber(Class<T> rawType) {
final TypeLiteral<T> type = TypeLiteral.get(rawType);
final TypeArgument<T> typeArg = new TypeArgument<T>(type){};
final TypeLiteral<NumberParser<T>> parserType = new ResolvableType<NumberParser<T>>(){}.with(typeArg);
bind(parserType);
bind(new ResolvableType<TransfiniteParser<T>>(){}.with(typeArg)).to(parserType);
bind(new ResolvableType<PrimitiveParser<T>>(){}.with(typeArg)).to(parserType);
bind(new ResolvableType<Parser<T>>(){}.with(typeArg)).to(parserType);
final TypeLiteral<VectorParser<T>> vectorParserType = new ResolvableType<VectorParser<T>>(){}.with(typeArg);
bind(vectorParserType);
install(new PropertyManifest<>(type, new ResolvableType<NumberProperty<T>>(){}.with(typeArg)));
if(Types.isAssignable(Comparable.class, type)) {
install(new RangeParserManifest(type));
}
}
示例2: driftClientTypeLiteral
import com.google.inject.TypeLiteral; //导入方法依赖的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);
}
示例3: forInnerClass
import com.google.inject.TypeLiteral; //导入方法依赖的package包/类
public static <I> InnerFactoryManifest<?, I> forInnerClass(Key<I> key) {
final Class<?> outer = key.getTypeLiteral().getRawType().getEnclosingClass();
if(outer == null) {
throw new IllegalArgumentException(key + " is not an inner class");
}
return new InnerFactoryManifest(key, TypeLiteral.get(outer));
}
示例4: bindTracker
import com.google.inject.TypeLiteral; //导入方法依赖的package包/类
protected <T> TrackerProvider<T> bindTracker(java.lang.reflect.Type typeParam, Annotation annotatedWith,
String extensionPoint, String beanParameter)
{
ParameterizedType type = Types.newParameterizedType(PluginTracker.class, typeParam);
TrackerProvider<T> trackerProvider = new TrackerProvider<T>(getPluginId(), extensionPoint, beanParameter);
@SuppressWarnings("unchecked")
TypeLiteral<PluginTracker<T>> typeLiteral = (TypeLiteral<PluginTracker<T>>) TypeLiteral.get(type);
LinkedBindingBuilder<PluginTracker<T>> bindingBuilder = bind(typeLiteral);
if( annotatedWith != null )
{
bindingBuilder = ((AnnotatedBindingBuilder<PluginTracker<T>>) bindingBuilder).annotatedWith(annotatedWith);
}
bindingBuilder.toProvider(trackerProvider).in(Scopes.SINGLETON);
return trackerProvider;
}
示例5: RootFeatureManifest
import com.google.inject.TypeLiteral; //导入方法依赖的package包/类
public RootFeatureManifest(@Nullable Class<T> type, @Nullable NodeFinder nodeFinder) {
this(type == null ? null : TypeLiteral.get(type), nodeFinder);
}
示例6: FeatureBinder
import com.google.inject.TypeLiteral; //导入方法依赖的package包/类
public FeatureBinder(Binder binder, Class<T> type) {
this(binder, TypeLiteral.get(type));
}
示例7: FeatureManifest
import com.google.inject.TypeLiteral; //导入方法依赖的package包/类
public FeatureManifest(@Nullable Class<T> T) {
this(TypeLiteral.get(T));
}
示例8: NumberParser
import com.google.inject.TypeLiteral; //导入方法依赖的package包/类
private NumberParser(Class<T> type) {
this(TypeLiteral.get(type), NumberFactory.get(type));
}
示例9: EnumParserManifest
import com.google.inject.TypeLiteral; //导入方法依赖的package包/类
public EnumParserManifest(Class<T> type) {
this(TypeLiteral.get(type));
}
示例10: PropertyManifest
import com.google.inject.TypeLiteral; //导入方法依赖的package包/类
public PropertyManifest(Class<T> type) {
this(TypeLiteral.get(type));
}
示例11: where
import com.google.inject.TypeLiteral; //导入方法依赖的package包/类
public TypeLiteral<T> where(TypeVariable<?> typeVariable, TypeLiteral<?> type) {
final TypeResolver resolver = new TypeResolver().where(typeVariable, type.getType());
return (TypeLiteral<T>) TypeLiteral.get(resolver.resolveType(getType()));
}
示例12: EnumParserManifest
import com.google.inject.TypeLiteral; //导入方法依赖的package包/类
public EnumParserManifest(Class<T> T) {
this(TypeLiteral.get(T));
}
示例13: parameterizedTypeLiteral
import com.google.inject.TypeLiteral; //导入方法依赖的package包/类
public static TypeLiteral parameterizedTypeLiteral(Type owner, Type... args) {
return TypeLiteral.get(com.google.inject.util.Types.newParameterizedType(owner, (Type[]) args));
}
示例14: MethodScanner
import com.google.inject.TypeLiteral; //导入方法依赖的package包/类
public MethodScanner(Class<D> decl, Predicate<? super Method> filter) {
this(TypeLiteral.get(decl), filter);
}
示例15: providedType
import com.google.inject.TypeLiteral; //导入方法依赖的package包/类
/**
* Return the type provided by the given {@link Provider}
*/
public static <T> TypeLiteral<T> providedType(TypeLiteral<? extends Provider<T>> providerType) {
return (TypeLiteral<T>) TypeLiteral.get(((ParameterizedType) providerType.getType()).getActualTypeArguments()[0]);
}