当前位置: 首页>>代码示例>>Java>>正文


Java TypeLiteral类代码示例

本文整理汇总了Java中com.google.inject.TypeLiteral的典型用法代码示例。如果您正苦于以下问题:Java TypeLiteral类的具体用法?Java TypeLiteral怎么用?Java TypeLiteral使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TypeLiteral类属于com.google.inject包,在下文中一共展示了TypeLiteral类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: configure

import com.google.inject.TypeLiteral; //导入依赖的package包/类
@Override
protected void configure() {
    install(new StateModule(timeout));
    if (eventLoopGroup.isPresent()) {
        install(new RpcModule(local.address(), eventLoopGroup.get()));
    } else {
        install(new RpcModule(local.address()));
    }
    
    install(new LogModule(logDir, stateMachine));

    bind(Replica.class).annotatedWith(LocalReplicaInfo.class).toInstance(local);

    bind(new TypeLiteral<List<Replica>>() {
    }).annotatedWith(ClusterMembers.class).toInstance(members);

    bind(RaftService.class);
    expose(RaftService.class);

}
 
开发者ID:lemonJun,项目名称:TakinRPC,代码行数:21,代码来源:RaftModule.java

示例2: configure

import com.google.inject.TypeLiteral; //导入依赖的package包/类
@Override
protected void configure() {
    bind(SelectionModulePresenter.class).to(SelectionModulePresenterImpl.class);
    bind(SelectionModuleView.class).to(SelectionModuleViewImpl.class);
    bind(SelectionElementGenerator.class).to(SelectionGridElementGeneratorImpl.class);
    bind(SelectionElementPositionGenerator.class).to(SelectionGridElementGeneratorImpl.class);

    bindModuleScoped(SelectionModuleModel.class, new TypeLiteral<ModuleScopedProvider<SelectionModuleModel>>() {
    });
    bindModuleScoped(SelectionModuleView.class, new TypeLiteral<ModuleScopedProvider<SelectionModuleView>>() {
    });
    bindModuleScoped(SelectionViewBuilder.class, new TypeLiteral<ModuleScopedProvider<SelectionViewBuilder>>() {
    });

    install(new GinFactoryModuleBuilder().build(SelectionModuleFactory.class));
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:17,代码来源:SelectionGinModule.java

示例3: 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));
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:20,代码来源:ParserManifest.java

示例4: ifCommmandIsInvalidExceptionIsThrown

import com.google.inject.TypeLiteral; //导入依赖的package包/类
@Test
public void ifCommmandIsInvalidExceptionIsThrown() throws IOException, URISyntaxException {
    String command = "invalid";
    Map<String, Object> opts = new HashMap<>();
    opts.put(BROWSER, CHROME);
    opts.put(DRIVER, chromedriverFile.getAbsolutePath());
    opts.put(APPLICATION, configurationFile.getAbsolutePath());
    opts.put(URL, localhostUrl);
    opts.put(CASE, caseFile.getAbsolutePath());
    opts.put(SCREEN, screenString);
    opts.put(TIMEOUT, timeoutString);
    opts.put(PRECISION, precisionString);
    Module module = new DefaultModule(command, opts);
    Injector injector = Guice.createInjector(module);

    try {
        RequestFilter instance = injector.getInstance(
                Key.get(new TypeLiteral<IOProvider<RequestFilter>>() {})).get();
    } catch (ProvisionException e) {
        assertTrue(e.getCause() instanceof NoSuchCommandException);
    }
}
 
开发者ID:hristo-vrigazov,项目名称:bromium,代码行数:23,代码来源:DefaultModuleTest.java

示例5: scanForMethods

import com.google.inject.TypeLiteral; //导入依赖的package包/类
@Test
public void scanForMethods() throws Exception {
    class Woot {
        @Yay String foo() {
            return "foo";
        }

        String bar() {
            return "bar";
        }
    }

    List<InjectableMethod<?>> methods = InjectableMethod.forAnnotatedMethods(TypeLiteral.get(Woot.class), new Woot(), Yay.class);
    Injector injector = Guice.createInjector(Lists.transform(methods, InjectableMethod::bindingModule));

    assertEquals("foo", injector.getInstance(String.class));
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:18,代码来源:InjectableMethodTest.java

示例6: visit

import com.google.inject.TypeLiteral; //导入依赖的package包/类
@Override
public Optional<TypeLiteral<?>> visit(ExposedBinding<?> binding) {
    // Lookup the exposed key in the private environment.
    // Since this visitor can only be used on an injector binding,
    // the private child injector should always be present too.
    return ofNullable(binding.getPrivateElements().getInjector())
        .flatMap(child -> child.getBinding(binding.getKey())
                               .acceptTargetVisitor(new BindingTargetTypeResolver(child)));
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:10,代码来源:BindingTargetTypeResolver.java

示例7: configure

import com.google.inject.TypeLiteral; //导入依赖的package包/类
@Override
protected void configure() {
    bind(BukkitCommandRegistry.class);
    bind(CommandRegistry.class).to(BukkitCommandRegistry.class);
    bind(new TypeLiteral<CommandRegistryImpl<CommandSender>>(){}).to(BukkitCommandRegistry.class);

    new ListenerBinder(binder())
        .bindListener().to(BukkitCommandRegistry.class);
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:10,代码来源:BukkitCommandManifest.java

示例8: 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;
}
 
开发者ID:equella,项目名称:Equella,代码行数:16,代码来源:PluginTrackerModule.java

示例9: InnerFactoryManifest

import com.google.inject.TypeLiteral; //导入依赖的package包/类
public InnerFactoryManifest(Key<I> innerKey, TypeLiteral<O> outerType) {
    if(innerKey == null) {
        innerKey = Key.get(new ResolvableType<I>(){}.in(getClass()));
    }
    this.innerType = innerKey.getTypeLiteral();
    this.outerType = outerType != null ? outerType : new ResolvableType<O>(){}.in(getClass());

    this.factoryKey = innerKey.ofType(new ResolvableType<InnerFactory<O, I>>(){}
                                          .with(new TypeArgument<O>(this.outerType){},
                                                new TypeArgument<I>(this.innerType){}));
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:12,代码来源:InnerFactoryManifest.java

示例10: forInheritedMethods

import com.google.inject.TypeLiteral; //导入依赖的package包/类
public static <D> List<InjectableMethod<?>> forInheritedMethods(@Nullable TypeLiteral<D> targetType, @Nullable D target, Predicate<? super Method> filter) {
    final TypeLiteral<D> finalTargetType = targetType(targetType, target, null);
    return new MethodScanner<>(finalTargetType, filter)
        .methods()
        .stream()
        .map(method -> (InjectableMethod<?>) forMethod(finalTargetType, target, method))
        .collect(Collectors.toImmutableList());
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:9,代码来源:InjectableMethod.java

示例11: configure

import com.google.inject.TypeLiteral; //导入依赖的package包/类
@Override
protected void configure() {
    bind(TextFeedback.class).to(TextFeedbackPresenter.class);
    bind(ImageFeedback.class).to(ImageFeedbackPresenter.class);
    bind(FeedbackBlendView.class).to(FeedbackBlendViewImpl.class);

    bindPageScoped(PowerFeedbackMediator.class, new TypeLiteral<PageScopedProvider<PowerFeedbackMediator>>() {
    });

    install(new GinFactoryModuleBuilder().build(FeedbackModuleFactory.class));
    install(new GinFactoryModuleBuilder().build(SingleFeedbackSoundPlayerFactory.class));
    install(new GinFactoryModuleBuilder().build(MatcherRegistryFactory.class));
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:14,代码来源:FeedbackGinModule.java

示例12: configure

import com.google.inject.TypeLiteral; //导入依赖的package包/类
@Override
protected void configure() {
    publicBinder().forOptional(UserService.class)
                  .setDefault().to(LocalUserService.class);

    bindAndExpose(new TypeLiteral<UserStore<Player>>(){})
        .to((Class) UserStore.class);

    bindAndExpose(new TypeLiteral<OnlinePlayers<Player>>(){})
        .to((Class) OnlinePlayers.class);
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:12,代码来源:MinecraftUsersManifest.java

示例13: FactoryBinding

import com.google.inject.TypeLiteral; //导入依赖的package包/类
FactoryBinding(Map<Key<?>, TypeLiteral<?>> collector, Key<?> factoryKey, Context context, GuiceUtil guiceUtil, MethodCallUtil methodCallUtil) {
    super(context, factoryKey);

    this.collector = Preconditions.checkNotNull(collector);
    this.factoryKey = factoryKey;
    this.factoryType = factoryKey.getTypeLiteral();
    this.guiceUtil = guiceUtil;
    this.methodCallUtil = methodCallUtil;

    try {
        matchMethods(Preconditions.checkNotNull(factoryKey));
    } catch (ErrorsException e) {
        e.getErrors().throwConfigurationExceptionIfErrorsExist();
    }
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:16,代码来源:FactoryBinding.java

示例14: dependencyType

import com.google.inject.TypeLiteral; //导入依赖的package包/类
/**
 * Return the type that is depended on by injecting the given type.
 * These types are the same, unless the injected type is a {@link Provider},
 * in which case the dependency is on the provided type.
 */
public static TypeLiteral<?> dependencyType(TypeLiteral<?> injectedType) {
    if(isImplicitProvider(injectedType)) {
        return providedType((TypeLiteral<? extends Provider<Object>>) injectedType);
    } else {
        return injectedType;
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:13,代码来源:Injection.java

示例15: MemberInjectingFactory

import com.google.inject.TypeLiteral; //导入依赖的package包/类
@Inject public MemberInjectingFactory(TypeLiteral<T> type, MembersInjector<T> injector) {
    this.type = type;
    this.injector = injector;
    this.injectionPoint = InjectionPoint.forConstructorOf(type);
    this.constructor = (Constructor<T>) injectionPoint.getMember();
    this.constructor.setAccessible(true);

    dependencies.addAll(Dependency.forInjectionPoints(InjectionPoint.forInstanceMethodsAndFields(type)));
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:10,代码来源:MemberInjectingFactory.java


注:本文中的com.google.inject.TypeLiteral类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。