Interface InjectableInstance<T>

Type Parameters:
T -
All Superinterfaces:
jakarta.enterprise.inject.Instance<T>, Iterable<T>, jakarta.inject.Provider<T>
All Known Implementing Classes:
InstanceImpl

public interface InjectableInstance<T> extends jakarta.enterprise.inject.Instance<T>
Enhanced version of Instance.
  • Nested Class Summary

    Nested classes/interfaces inherited from interface jakarta.enterprise.inject.Instance

    jakarta.enterprise.inject.Instance.Handle<T>
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Removes the cached result of the Provider.get() operation.
    default T
    Returns exactly one instance of an active bean that matches the required type and qualifiers.
     
     
     
    This method attempts to resolve ambiguities.
    default List<T>
    Returns the list of instances of active beans that match the required type and qualifiers, sorter in priority order (higher priority goes first).
    default T
    orElse(T other)
    If there is exactly one bean that matches the required type and qualifiers, returns the instance, otherwise returns other.
    default T
    If there is exactly one bean that matches the required type and qualifiers, returns the instance, otherwise returns null.
    <U extends T>
    InjectableInstance<U>
    select(jakarta.enterprise.util.TypeLiteral<U> subtype, Annotation... qualifiers)
     
    select(Annotation... qualifiers)
     
    <U extends T>
    InjectableInstance<U>
    select(Class<U> subtype, Annotation... qualifiers)
     

    Methods inherited from interface jakarta.enterprise.inject.Instance

    destroy, isAmbiguous, isResolvable, isUnsatisfied, stream

    Methods inherited from interface java.lang.Iterable

    forEach, spliterator

    Methods inherited from interface jakarta.inject.Provider

    get
  • Method Details

    • getHandle

      InstanceHandle<T> getHandle()
      Specified by:
      getHandle in interface jakarta.enterprise.inject.Instance<T>
    • handles

      Specified by:
      handles in interface jakarta.enterprise.inject.Instance<T>
    • handlesStream

      default Stream<InstanceHandle<T>> handlesStream()
      Specified by:
      handlesStream in interface jakarta.enterprise.inject.Instance<T>
    • select

      InjectableInstance<T> select(Annotation... qualifiers)
      Specified by:
      select in interface jakarta.enterprise.inject.Instance<T>
    • select

      <U extends T> InjectableInstance<U> select(Class<U> subtype, Annotation... qualifiers)
      Specified by:
      select in interface jakarta.enterprise.inject.Instance<T>
    • select

      <U extends T> InjectableInstance<U> select(jakarta.enterprise.util.TypeLiteral<U> subtype, Annotation... qualifiers)
      Specified by:
      select in interface jakarta.enterprise.inject.Instance<T>
    • clearCache

      void clearCache()
      Removes the cached result of the Provider.get() operation. If the cached result was a contextual reference of a Dependent bean, destroy the reference as well.
      See Also:
    • iterator

      Iterator<T> iterator()
      This method attempts to resolve ambiguities.

      In general, if multiple beans are eligible then the container eliminates all beans that are:

      • not alternatives, except for producer methods and fields of beans that are alternatives,
      • default beans.
      Specified by:
      iterator in interface Iterable<T>
      Returns:
      an iterator over the contextual references of the disambiguated beans
      See Also:
    • orElse

      default T orElse(T other)
      If there is exactly one bean that matches the required type and qualifiers, returns the instance, otherwise returns other.
      Parameters:
      other -
      Returns:
      the bean instance or the other value
    • orNull

      default T orNull()
      If there is exactly one bean that matches the required type and qualifiers, returns the instance, otherwise returns null.
      Returns:
      the bean instance or null
    • getActive

      default T getActive()
      Returns exactly one instance of an active bean that matches the required type and qualifiers. If no active bean matches, or if more than one active bean matches, throws an exception.
      Returns:
      the single instance of an active matching bean
    • listActive

      default List<T> listActive()
      Returns the list of instances of active beans that match the required type and qualifiers, sorter in priority order (higher priority goes first).
      Returns:
      the list of instances of matching active beans