Interface Container

    • Method Detail

      • getInstance

        @Deprecated(forRemoval=true,
                    since="7")
        default <T> T getInstance​(com.google.inject.Key<T> key)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Use getInstance(Class) instead.
        Returns the appropriate instance for the given injection key. When feasible, avoid using this method in favor of having Guice inject your dependencies ahead of time.
        Type Parameters:
        T - The class of the instance to return.
        Parameters:
        key - The key of the instance to return.
        Returns:
        The appropriate instance of the given class.
        Throws:
        com.google.inject.ConfigurationException - If this injector cannot find or create the provider.
        com.google.inject.ProvisionException - If there was a runtime failure while providing an instance.
      • getInstance

        <T> T getInstance​(Class<T> type)
        Returns the appropriate instance for the given injection type. When feasible, avoid using this method in favor of having Guice inject your dependencies ahead of time.
        Type Parameters:
        T - The class of the instance to return.
        Parameters:
        type - The class object of the instance to return.
        Returns:
        The appropriate instance of the given class.
        Throws:
        com.google.inject.ConfigurationException - If this injector cannot find or create the provider.
        com.google.inject.ProvisionException - If there was a runtime failure while providing an instance.