Java Code Examples for com.google.inject.binder.AnnotatedBindingBuilder#toInstance()

The following examples show how to use com.google.inject.binder.AnnotatedBindingBuilder#toInstance() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IndexOnlyProjectTest.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public com.google.inject.Module getServerModule() {
  ServerModule _serverModule = new ServerModule();
  final com.google.inject.Module _function = (Binder it) -> {
    AnnotatedBindingBuilder<IMultiRootWorkspaceConfigFactory> _bind = it.<IMultiRootWorkspaceConfigFactory>bind(IMultiRootWorkspaceConfigFactory.class);
    _bind.toInstance(new MultiRootWorkspaceConfigFactory() {
      @Override
      public void addProjectsForWorkspaceFolder(final WorkspaceConfig workspaceConfig, final WorkspaceFolder workspaceFolder, final Set<String> existingNames) {
        String _uri = null;
        if (workspaceFolder!=null) {
          _uri=workspaceFolder.getUri();
        }
        boolean _tripleNotEquals = (_uri != null);
        if (_tripleNotEquals) {
          URI _uri_1 = this.getUriExtensions().toUri(workspaceFolder.getUri());
          String _uniqueProjectName = this.getUniqueProjectName(workspaceFolder.getName(), existingNames);
          final FileProjectConfig project = new FileProjectConfig(_uri_1, _uniqueProjectName) {
            @Override
            public boolean isIndexOnly() {
              return true;
            }
          };
          project.addSourceFolder(".");
          workspaceConfig.addProject(project);
        }
      }
    });
  };
  return Modules2.mixin(_serverModule, _function);
}
 
Example 2
Source File: MockDaoSecurityModule.java    From arcusplatform with Apache License 2.0 4 votes vote down vote up
@Override
protected void bindAuthenticationDAO(AnnotatedBindingBuilder<AuthenticationDAO> bind) {
   bind.toInstance(EasyMock.createMock(AuthenticationDAO.class));
   expose(AuthenticationDAO.class);
}
 
Example 3
Source File: MockDaoSecurityModule.java    From arcusplatform with Apache License 2.0 4 votes vote down vote up
@Override
protected void bindSessionDAO(AnnotatedBindingBuilder<SessionDAO> bind) {
   bind.toInstance(EasyMock.createMock(SessionDAO.class));
   expose(SessionDAO.class);
}
 
Example 4
Source File: AbstractGeneratorFragmentTests.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
public void configureIXtextProjectConfig(final Binder binder) {
  AnnotatedBindingBuilder<IXtextProjectConfig> _bind = binder.<IXtextProjectConfig>bind(IXtextProjectConfig.class);
  AbstractGeneratorFragmentTests.FakeProjectConfig _fakeProjectConfig = new AbstractGeneratorFragmentTests.FakeProjectConfig();
  _bind.toInstance(_fakeProjectConfig);
}