Java 类com.google.inject.TypeLiteral 实例源码

项目:TakinRPC    文件:RaftModule.java   
@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);

}
项目:empiria.player    文件:SelectionGinModule.java   
@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));
}
项目:ProjectAres    文件:ParserManifest.java   
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));
    }
}
项目:bromium    文件:DefaultModuleTest.java   
@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);
    }
}
项目:ProjectAres    文件:InjectableMethodTest.java   
@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));
}
项目:ProjectAres    文件:BindingTargetTypeResolver.java   
@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)));
}
项目:ProjectAres    文件:BukkitCommandManifest.java   
@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);
}
项目:Equella    文件:PluginTrackerModule.java   
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;
}
项目:ProjectAres    文件:InnerFactoryManifest.java   
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){}));
}
项目:ProjectAres    文件:InjectableMethod.java   
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());
}
项目:empiria.player    文件:FeedbackGinModule.java   
@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));
}
项目:ProjectAres    文件:MinecraftUsersManifest.java   
@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);
}
项目:empiria.player    文件:FactoryBinding.java   
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();
    }
}
项目:ProjectAres    文件:Injection.java   
/**
 * 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;
    }
}
项目:ProjectAres    文件:MemberInjectingFactory.java   
@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)));
}
项目:ProjectAres    文件:PropertyManifest.java   
public PropertyManifest(TypeLiteral<T> type, TypeLiteral<B> builderType, boolean defaultForType) {
    this.type = Types.assertFullySpecified(checkNotNull(type));
    this.builderType = Types.assertFullySpecified(checkNotNull(builderType));
    this.typeArg = new TypeArgument<T>(this.type){};
    this.builderTypeArg = new TypeArgument<B>(this.builderType){};
    this.defaultForType = defaultForType;
}
项目:empiria.player    文件:TestGuiceModule.java   
private void addPostConstructInterceptor(GuiceModuleConfiguration guiceModuleConfiguration) {
    HasPostConstructMethod hasPostConstruct = new HasPostConstructMethod(guiceModuleConfiguration.getClassWithDisabledPostConstruct());
    final PostConstructInvoker postConstructInvoker = new PostConstructInvoker();
    bindListener(hasPostConstruct, new TypeListener() {
        @Override
        public <I> void hear(TypeLiteral<I> type, TypeEncounter<I> encounter) {
            encounter.register(postConstructInvoker);
        }
    });
}
项目:wall-t    文件:ApiModuleTest.java   
@Test
public void can_inject_functions_to_build_BuildData_in_singleton( ) throws Exception {
    // Setup
    // Exercise
    final Map<ApiVersion, Function<Build, BuildData>> instance = _injector.getInstance( Key.get( new TypeLiteral<Map<ApiVersion, Function<Build, BuildData>>>( ) {
    } ) );
    final Map<ApiVersion, Function<Build, BuildData>> instance2 = _injector.getInstance( Key.get( new TypeLiteral<Map<ApiVersion, Function<Build, BuildData>>>( ) {
    } ) );
    // Verify
    assertThat( instance, is( notNullValue( ) ) );
    assertThat( instance, is( sameInstance( instance2 ) ) );
}
项目:wall-t    文件:ApiModuleTest.java   
@Test
public void can_inject_functions_to_build_ProjectData_in_singleton( ) throws Exception {
    // Setup
    // Exercise
    final Map<ApiVersion, Function<Project, ProjectData>> instance = _injector.getInstance( Key.get( new TypeLiteral<Map<ApiVersion, Function<Project, ProjectData>>>( ) {
    } ) );
    final Map<ApiVersion, Function<Project, ProjectData>> instance2 = _injector.getInstance( Key.get( new TypeLiteral<Map<ApiVersion, Function<Project, ProjectData>>>( ) {
    } ) );
    // Verify
    assertThat( instance, is( notNullValue( ) ) );
    assertThat( instance, is( sameInstance( instance2 ) ) );
}
项目:verify-hub    文件:SamlProxyModuleTest.java   
@Test
public void configure() {
    // Given
    SamlProxyModule sem = new SamlProxyModule();
    when(binder.bind(any(Class.class))).thenReturn(builder);
    when(binder.bind(any(TypeLiteral.class))).thenReturn(builder);
    when(builder.toProvider(any(Class.class))).thenReturn(scopedBindingBuilder);

    // When
    sem.configure(binder);

    // Then
    verify(binder).bind(TrustStoreConfiguration.class);
}
项目:verify-hub    文件:SamlEngineModule.java   
@Override
protected void configure() {
    bind(TrustStoreConfiguration.class).to(SamlEngineConfiguration.class);
    bind(RestfulClientConfiguration.class).to(SamlEngineConfiguration.class);
    bind(SamlDuplicateRequestValidationConfiguration.class).to(SamlEngineConfiguration.class);
    bind(SamlAuthnRequestValidityDurationConfiguration.class).to(SamlEngineConfiguration.class);
    bind(Client.class).toProvider(DefaultClientProvider.class).asEagerSingleton();
    bind(EntityToEncryptForLocator.class).to(AssignableEntityToEncryptForLocator.class);
    bind(AssignableEntityToEncryptForLocator.class).asEagerSingleton();
    bind(InfinispanStartupTasks.class).asEagerSingleton();
    bind(ConfigServiceKeyStore.class).asEagerSingleton();
    bind(JsonResponseProcessor.class);
    bind(RpErrorResponseGeneratorService.class);
    bind(TransactionsConfigProxy.class);
    bind(MatchingServiceHealthcheckRequestGeneratorService.class);
    bind(ObjectMapper.class).toInstance(new ObjectMapper());
    bind(ExpiredCertificateMetadataFilter.class).toInstance(new ExpiredCertificateMetadataFilter());
    bind(new TypeLiteral<LevelLoggerFactory<SamlEngineExceptionMapper>>() {})
        .toInstance(new LevelLoggerFactory<>());
    bind(OutboundResponseFromHubToResponseTransformerFactory.class);
    bind(SimpleProfileOutboundResponseFromHubToResponseTransformerProvider.class);
    bind(SimpleProfileOutboundResponseFromHubToSamlResponseTransformer.class);
    bind(ResponseToUnsignedStringTransformer.class);
    bind(ResponseAssertionSigner.class);
    bind(SimpleProfileTransactionIdaStatusMarshaller.class);
    bind(IdpAuthnResponseTranslatorService.class);
    bind(InboundResponseFromIdpDataGenerator.class);
    bind(MatchingServiceRequestGeneratorService.class);
    bind(HubAttributeQueryRequestBuilder.class);
    bind(MatchingServiceResponseTranslatorService.class);
    bind(RpAuthnRequestTranslatorService.class);
    bind(RpAuthnResponseGeneratorService.class);
    bind(IdpAuthnRequestGeneratorService.class);
    bind(CountrySingleSignOnServiceHelper.class);
    bind(IdaAuthnRequestTranslator.class);
    bind(EidasAuthnRequestTranslator.class);
    bind(MatchingServiceHealthcheckResponseTranslatorService.class);
}
项目:ProjectAres    文件:InjectingFactory.java   
public InjectingFactory(Binder binder, TypeLiteral<T> type) {
    super(type, binder.getMembersInjector(type));
    this.providers = injectionPoint.getDependencies()
                                   .stream()
                                   .map(binder::getProvider)
                                   .collect(Collectors.toImmutableList());
    dependencies.addAll(injectionPoint.getDependencies());
}
项目:bromium    文件:DefaultModule.java   
@Override
protected void configure() {
    bind(BaseRecorderFunctionFactory.class).to(PredefinedRecorderFunctionFactory.class);
    bind(FunctionRegistry.class).to(RecorderFunctionRegistry.class);
    bind(javascriptGeneratorByNameAndWebDriverActionConfiguration)
            .to(new TypeLiteral<IncludeInvokeGenerator<NameWebDriverActionConfiguration>>() {});
    bind(new TypeLiteral<JavascriptGenerator<ApplicationActionConfiguration>>(){})
            .to(RecordingWebDriverActionsOnly.class);
    bind(new TypeLiteral<FunctionRegistry<NameWebDriverActionConfiguration>>(){})
            .to(RecorderFunctionRegistry.class);
    bind(new TypeLiteral<Predicate<HttpRequest>>() {})
            .annotatedWith(Names.named(SHOULD_INJECT_JS_PREDICATE))
            .to(GetHtmlFromCurrentHostPredicate.class);

    bind(HttpRequestToTestCaseStepConverter.class)
            .annotatedWith(Names.named(CONVENTION_EVENT_DETECTOR_CONVERTOR))
            .to(SplitQueryStringOfRequest.class);

    bind(syntaxASTconverter).to(SyntaxDefinitionASTNodeConverter.class);
    bind(actionASTconverter).to(ActionASTNodeConverter.class);
    bind(conditionASTconverter).to(ConditionASTNodeConverter.class);
    bind(applicationActionASTconverter).to(ApplicationActionASTNodeConverter.class);
    bind(modelASTconverter).to(TraversingBasedASTNodeConverter.class);

    bind(ApplicationConfigurationParser.class).to(DslParser.class);

    // TODO: other OSes should have a different binding
    bind(VirtualScreenProcessCreator.class).to(UbuntuVirtualScreenProcessCreator.class);
    bindConstant().annotatedWith(Names.named(RECORD_TEMPLATE_RESOURCE)).to("/record.js");
    bindConstant().annotatedWith(Names.named(REPLAY_TEMPLATE_RESOURCE)).to("/replay.js");

    // state
    bind(RecordingState.class).in(Singleton.class);
    bind(ReplayingState.class).in(Singleton.class);

    install(ThrowingProviderBinder.forModule(this));
}
项目:drift    文件:ThriftCodecModule.java   
@Override
public void configure(Binder binder)
{
    binder.bind(ThriftCodecFactory.class).to(CompilerThriftCodecFactory.class).in(Scopes.SINGLETON);
    binder.bind(ThriftCatalog.class).in(Scopes.SINGLETON);
    binder.bind(ThriftCodecManager.class).in(Scopes.SINGLETON);
    newSetBinder(binder, new TypeLiteral<ThriftCodec<?>>() {}, InternalThriftCodec.class).permitDuplicates();

    binder.bind(ClassLoader.class)
            .annotatedWith(ForCompiler.class)
            .toInstance(parent);
}
项目:act-platform    文件:DaoModule.java   
@Override
protected void configure() {
  // Cassandra
  bind(ClusterManager.class).toProvider(ClusterManagerProvider.class).in(Scopes.SINGLETON);
  bind(EntityHandlerFactory.class).to(DefaultEntityHandlerFactory.class).in(Scopes.SINGLETON);
  bind(FactManager.class);
  bind(ObjectManager.class);

  // ElasticSearch
  bind(ClientFactory.class).toProvider(ClientFactoryProvider.class).in(Scopes.SINGLETON);
  bind(new TypeLiteral<Function<UUID, EntityHandler>>() {}).to(EntityHandlerForTypeIdResolver.class);
  bind(FactSearchManager.class);
}
项目:ProjectAres    文件:InnerFactoryManifest.java   
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));
}
项目:wall-t    文件:ApiModuleTest.java   
@Test
public void can_inject_functions_to_build_BuildTypeData_in_singleton( ) throws Exception {
    // Setup
    // Exercise
    final Map<ApiVersion, Function<BuildType, BuildTypeData>> instance = _injector.getInstance( Key.get( new TypeLiteral<Map<ApiVersion, Function<BuildType, BuildTypeData>>>( ) {
    } ) );
    final Map<ApiVersion, Function<BuildType, BuildTypeData>> instance2 = _injector.getInstance( Key.get( new TypeLiteral<Map<ApiVersion, Function<BuildType, BuildTypeData>>>( ) {
    } ) );
    // Verify
    assertThat( instance, is( notNullValue( ) ) );
    assertThat( instance, is( sameInstance( instance2 ) ) );
}
项目:Equella    文件:WizardModule.java   
@Override
protected void configure()
{
    NodeProvider rootNode = node(RootWizardSection.class);
    rootNode.child(PreviewSection.class);
    rootNode.child(wizardNav());
    rootNode.child(SelectThumbnailSection.class);
    bind(Object.class).annotatedWith(Names.named("/access/runwizard")).toProvider(rootNode);

    ListProvider<WizardCommand> commands = new ListProvider<WizardCommand>(binder(),
        ImmutableList.of(EditInWizard.class, ViewSummary.class, Approve.class, Reject.class, SaveAndContinue.class, Preview.class, Save.class,
            Cancel.class, SelectThumbnail.class));
    ListProvider<SectionId> additional = new ListProvider<SectionId>(binder());
    additional.add(LockedByGroupSection.class);

    bind(new TypeLiteral<List<WizardCommand>>()
    {
    }).toProvider(commands);
    bind(new TypeLiteral<List<SectionId>>()
    {
    }).toProvider(additional);
    bind(WizardExtendedFactory.class).annotatedWith(Names.named("TitleFactory")).to(NamedTitleFactory.class)
        .asEagerSingleton();
    install(new WizardTracker());

    requestStaticInjection(WizardState.class);
}
项目:ProjectAres    文件:ResolvableType.java   
/**
 * Fully resolve this type by substituting this type's formal type
 * parameters with the given actual type arguments
 */
public TypeLiteral<T> with(TypeArgument<?>... arguments) {
    TypeToken<T> token = Types.toToken(this);
    for(TypeArgument arg : arguments) {
        token = token.where(arg, arg.actual());
    }
    return Types.assertFullySpecified(Types.toLiteral(token));
}
项目:ProjectAres    文件:ReflectiveParserManifest.java   
public ReflectiveParserManifest(TypeLiteral<T> type, Class<?> baseClass) {
    this.type = type;
    this.parserKey = Key.get(Types.parameterizedTypeLiteral(ReflectiveParser.class, type));
    this.baseClass = checkNotNull(baseClass);

    checkArgument(type.getRawType().isInterface());
}
项目:ProjectAres    文件:ModelBinder.java   
private ModelBinder(ProtectedBinder protectedBinder, TypeLiteral<M> M, TypeLiteral<P> P) {
    this.binder = Binders.wrap(protectedBinder.publicBinder());
    this.M = M;
    this.P = P;

    this.metas = Multibinder.newSetBinder(binder, ModelMeta.class);
    this.serviceBinder = OptionalBinder.newOptionalBinder(binder, ModelService(M, P));
    this.queryServiceBinder = OptionalBinder.newOptionalBinder(binder, QueryService(M));
    this.updateServiceBinder = OptionalBinder.newOptionalBinder(binder, UpdateService(P));
    this.storeBinder = OptionalBinder.newOptionalBinder(binder, ModelStore(M));

    binder.install(new OneTime());
    binder.install(new PerModel());
}
项目:Equella    文件:DependencyAnalyzer.java   
private void analyzeDependencies(final Collection<Dependency<?>> dependencies)
{
    for( final Dependency<?> d : dependencies )
    {
        final Key<?> key = d.getKey();
        InjectionPoint injectionPoint = d.getInjectionPoint();
        if( injectionPoint != null && injectionPoint.isOptional() )
        {
            continue;
        }
        if( key.getAnnotationType() == Assisted.class )
        {
            continue;
        }
        TypeLiteral<?> typeLiteral = key.getTypeLiteral();
        Class<?> rawType = typeLiteral.getRawType();
        if( rawType == Injector.class )
        {
            continue;
        }
        if( rawType == MembersInjector.class )
        {
            Key<?> injectedKey = key
                .ofType(((ParameterizedType) typeLiteral.getType()).getActualTypeArguments()[0]);
            dependentKeys.add(injectedKey);
            analyzeImplementation(injectedKey.getTypeLiteral(), true);
        }
        else if( rawType == Provider.class )
        {
            dependentKeys.add(key.ofType(((ParameterizedType) typeLiteral.getType()).getActualTypeArguments()[0]));
        }
        else
        {
            dependentKeys.add(key);
        }
    }
}
项目:wall-t    文件:ApiModuleTest.java   
@Test
public void has_functions_to_build_ProjectData_for_all_api_versions( ) throws Exception {
    // Setup
    // Exercise
    final Map<ApiVersion, Function<Project, ProjectData>> instance = _injector.getInstance( Key.get( new TypeLiteral<Map<ApiVersion, Function<Project, ProjectData>>>( ) {
    } ) );
    // Verify
    assertThat( instance.keySet( ), containsInAnyOrder( ApiVersion.values( ) ) );
}
项目:ProjectAres    文件:BungeePluginManifest.java   
@Override
protected void configure() {
    publicBinder().install(new BungeeServerManifest());
    install(new MinecraftPluginManifest());
    install(new BungeeSchedulerManifest());
    install(new PluginFacetManifest());

    bind(CommandRegistry.class).to(BungeeCommandRegistry.class);
    bind(new TypeLiteral<CommandRegistryImpl<CommandSender>>(){}).to(BungeeCommandRegistry.class);
}
项目:ProjectAres    文件:InjectableMethod.java   
public static <D> InjectableMethod<?> forDeclaredMethod(D target, String name, Class<?>... params) {
    return forDeclaredMethod((TypeLiteral<D>) null, target, name, params);
}
项目:ProjectAres    文件:Matchers.java   
public static Matcher<? extends Binding<?>> bindingsForSubtypesOf(Class<?> type) {
    return bindingsForSubtypesOf(TypeLiteral.get(type));
}
项目:ProjectAres    文件:ResolvableType.java   
public <X> TypeLiteral<T> where(TypeParameter<X> parameter, TypeLiteral<X> type) {
    return where(parameter, Types.toToken(type));
}
项目:ProjectAres    文件:TypeLiterals.java   
default <T> TypeLiteral<Optional<T>> Optional(TypeLiteral<T> type) {
    return new ResolvableType<Optional<T>>(){}.with(new TypeArgument<T>(type){});
}
项目:ProjectAres    文件:Types.java   
/**
 * Convert a Guava {@link TypeToken} to a Guice {@link TypeLiteral}
 */
public static <T> TypeLiteral<T> toLiteral(TypeToken<T> typeToken) {
    return (TypeLiteral<T>) TypeLiteral.get(typeToken.getType());
}
项目:ProjectAres    文件:Matchers.java   
public static Matcher<? extends Binding<?>> bindingsForSubtypesOf(TypeLiteral<?> type) {
    return bindingsForTypeLiterals((Matcher<TypeLiteral<?>>) subtypesOf(type));
}