Class GuiceDependencyInjector

java.lang.Object
com.github.thought2code.mcp.annotated.di.GuiceDependencyInjector
All Implemented Interfaces:
DependencyInjector

public final class GuiceDependencyInjector extends Object implements DependencyInjector
This class implements the DependencyInjector interface using Google Guice.
Author:
codeboyzhou
  • Constructor Details

    • GuiceDependencyInjector

      public GuiceDependencyInjector(com.google.inject.Injector injector)
      Creates a new instance of GuiceDependencyInjector with the specified Guice Injector.
      Parameters:
      injector - the Guice Injector to use for dependency injection
  • Method Details

    • getInstance

      public <T> T getInstance(Class<T> type)
      Description copied from interface: DependencyInjector
      Returns an instance of the specified type.
      Specified by:
      getInstance in interface DependencyInjector
      Type Parameters:
      T - the type of the instance to return
      Parameters:
      type - the class of the instance to return
      Returns:
      an instance of the specified type
    • getVariable

      public <T> T getVariable(Class<T> type, String name)
      Description copied from interface: DependencyInjector
      Returns the value of the specified variable.
      Specified by:
      getVariable in interface DependencyInjector
      Type Parameters:
      T - the type of the variable to return
      Parameters:
      type - the class of the variable to return
      name - the name of the variable to return
      Returns:
      the value of the specified variable
    • isInitialized

      public boolean isInitialized()
      Description copied from interface: DependencyInjector
      Returns whether the dependency injector is initialized.
      Specified by:
      isInitialized in interface DependencyInjector
      Returns:
      true if the dependency injector is initialized, false otherwise