接口 ObjectProvider<T>

    • 方法概要

      所有方法 实例方法 抽象方法 默认方法 
      修饰符和类型方法说明
      TgetIfAvailable()
      Return an instance (possibly shared or independent) of the object managed by this factory.
      default TgetIfAvailable​(Supplier<T> defaultSupplier)
      Return an instance (possibly shared or independent) of the object managed by this factory.
      TgetIfUnique()
      Return an instance (possibly shared or independent) of the object managed by this factory.
      default TgetIfUnique​(Supplier<T> defaultSupplier)
      Return an instance (possibly shared or independent) of the object managed by this factory.
      TgetObject​(Object... args)
      Return an instance (possibly shared or independent) of the object managed by this factory.
      default voidifAvailable​(Consumer<T> dependencyConsumer)
      Consume an instance (possibly shared or independent) of the object managed by this factory, if available.
      default voidifUnique​(Consumer<T> dependencyConsumer)
      Consume an instance (possibly shared or independent) of the object managed by this factory, if unique.
      default Iterator<T>iterator()
      Return an Iterator over all matching object instances, without specific ordering guarantees (but typically in registration order).
      default Stream<T>orderedStream()
      Return a sequential Stream over all matching object instances, pre-ordered according to the factory's common order comparator.
      default Stream<T>stream()
      Return a sequential Stream over all matching object instances, without specific ordering guarantees (but typically in registration order).
    • 方法详细资料

      • getIfAvailable

        default T getIfAvailable​(Supplier<T> defaultSupplier)
                          throws BeansException
        Return an instance (possibly shared or independent) of the object managed by this factory.
        参数:
        defaultSupplier - a callback for supplying a default object if none is present in the factory
        返回:
        an instance of the bean, or the supplied default object if no such bean is available
        抛出:
        BeansException - in case of creation errors
        从以下版本开始:
        5.0
        另请参阅:
        getIfAvailable()
      • ifAvailable

        default void ifAvailable​(Consumer<T> dependencyConsumer)
                          throws BeansException
        Consume an instance (possibly shared or independent) of the object managed by this factory, if available.
        参数:
        dependencyConsumer - a callback for processing the target object if available (not called otherwise)
        抛出:
        BeansException - in case of creation errors
        从以下版本开始:
        5.0
        另请参阅:
        getIfAvailable()
      • getIfUnique

        default T getIfUnique​(Supplier<T> defaultSupplier)
                       throws BeansException
        Return an instance (possibly shared or independent) of the object managed by this factory.
        参数:
        defaultSupplier - a callback for supplying a default object if no unique candidate is present in the factory
        返回:
        an instance of the bean, or the supplied default object if no such bean is available or if it is not unique in the factory (i.e. multiple candidates found with none marked as primary)
        抛出:
        BeansException - in case of creation errors
        从以下版本开始:
        5.0
        另请参阅:
        getIfUnique()
      • ifUnique

        default void ifUnique​(Consumer<T> dependencyConsumer)
                       throws BeansException
        Consume an instance (possibly shared or independent) of the object managed by this factory, if unique.
        参数:
        dependencyConsumer - a callback for processing the target object if unique (not called otherwise)
        抛出:
        BeansException - in case of creation errors
        从以下版本开始:
        5.0
        另请参阅:
        getIfAvailable()
      • iterator

        default Iterator<Titerator()
        Return an Iterator over all matching object instances, without specific ordering guarantees (but typically in registration order).
        指定者:
        iterator 在接口中 Iterable<T>
        从以下版本开始:
        5.1
        另请参阅:
        stream()
      • stream

        default Stream<Tstream()
        Return a sequential Stream over all matching object instances, without specific ordering guarantees (but typically in registration order).
        从以下版本开始:
        5.1
        另请参阅:
        iterator(), orderedStream()
      • orderedStream

        default Stream<TorderedStream()
        Return a sequential Stream over all matching object instances, pre-ordered according to the factory's common order comparator.

        In a standard Spring application context, this will be ordered according to Ordered conventions, and in case of annotation-based configuration also considering the Order annotation, analogous to multi-element injection points of list/array type.

        从以下版本开始:
        5.1
        另请参阅:
        stream(), OrderComparator