Class SimpleObjectProvider<T>

  • Type Parameters:
    T - the type parameter
    All Implemented Interfaces:
    Iterable<T>, org.springframework.beans.factory.ObjectFactory<T>, org.springframework.beans.factory.ObjectProvider<T>

    public class SimpleObjectProvider<T>
    extends Object
    implements org.springframework.beans.factory.ObjectProvider<T>
    The simple object provider.
    • Constructor Detail

      • SimpleObjectProvider

        public SimpleObjectProvider​(@Nullable
                                    T provides)
        Instantiates a new simple object provider.
        Parameters:
        provides - the provides
      • SimpleObjectProvider

        public SimpleObjectProvider​(@Nullable
                                    T provides,
                                    @Nullable
                                    Consumer<T> dependencyConsumer)
        Instantiates a new simple object provider.

        If a dependency consumer is set, the given consumer will be invoked when ObjectProvider.ifAvailable(Consumer) or ObjectProvider.ifUnique(Consumer) is called.

        Parameters:
        provides - the provides
        dependencyConsumer - the dependency consumer
    • Method Detail

      • getObject

        @NonNull
        public T getObject​(@NonNull
                           Object... objects)
                    throws org.springframework.beans.BeansException
        Specified by:
        getObject in interface org.springframework.beans.factory.ObjectProvider<T>
        Throws:
        org.springframework.beans.BeansException
      • ifAvailable

        public void ifAvailable​(@NonNull
                                Consumer<T> dependencyConsumer)
                         throws org.springframework.beans.BeansException
        Specified by:
        ifAvailable in interface org.springframework.beans.factory.ObjectProvider<T>
        Throws:
        org.springframework.beans.BeansException
      • ifUnique

        public void ifUnique​(@NonNull
                             Consumer<T> dependencyConsumer)
                      throws org.springframework.beans.BeansException
        Specified by:
        ifUnique in interface org.springframework.beans.factory.ObjectProvider<T>
        Throws:
        org.springframework.beans.BeansException
      • getIfAvailable

        public T getIfAvailable()
                         throws org.springframework.beans.BeansException
        Specified by:
        getIfAvailable in interface org.springframework.beans.factory.ObjectProvider<T>
        Throws:
        org.springframework.beans.BeansException
      • getIfUnique

        public T getIfUnique()
                      throws org.springframework.beans.BeansException
        Specified by:
        getIfUnique in interface org.springframework.beans.factory.ObjectProvider<T>
        Throws:
        org.springframework.beans.BeansException
      • getObject

        @NonNull
        public T getObject()
                    throws org.springframework.beans.BeansException
        Specified by:
        getObject in interface org.springframework.beans.factory.ObjectFactory<T>
        Throws:
        org.springframework.beans.BeansException