Interface InstanceSupplier<T>

Type Parameters:
T - the type of instance supplied by this supplier
All Superinterfaces:
Supplier<T>, org.springframework.util.function.ThrowingSupplier<T>
All Known Implementing Classes:
BeanInstanceSupplier
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface InstanceSupplier<T> extends org.springframework.util.function.ThrowingSupplier<T>
Specialized Supplier that can be set on a BeanDefinition when details about the registered bean are needed to supply the instance.
Since:
6.0
Author:
Phillip Webb, Stephane Nicoll
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    default <V> InstanceSupplier<V>
    andThen(org.springframework.util.function.ThrowingBiFunction<RegisteredBean,? super T,? extends V> after)
    Return a composed instance supplier that first obtains the instance from this supplier and then applies the after function to obtain the result.
    get(RegisteredBean registeredBean)
    Get the supplied instance.
    default Method
    Return the factory method that this supplier uses to create the instance, or null if it is not known or this supplier uses another means.
    default T
     
    static <T> InstanceSupplier<T>
    of(InstanceSupplier<T> instanceSupplier)
    Lambda friendly method that can be used to create an InstanceSupplier and add post processors in a single call.
    static <T> InstanceSupplier<T>
    using(Method factoryMethod, org.springframework.util.function.ThrowingSupplier<T> supplier)
    Factory method to create an InstanceSupplier from a ThrowingSupplier.
    static <T> InstanceSupplier<T>
    using(org.springframework.util.function.ThrowingSupplier<T> supplier)
    Factory method to create an InstanceSupplier from a ThrowingSupplier.

    Methods inherited from interface org.springframework.util.function.ThrowingSupplier

    get, get, throwing
  • Method Details

    • getWithException

      default T getWithException()
      Specified by:
      getWithException in interface org.springframework.util.function.ThrowingSupplier<T>
    • get

      T get(RegisteredBean registeredBean) throws Exception
      Get the supplied instance.
      Parameters:
      registeredBean - the registered bean requesting the instance
      Returns:
      the supplied instance
      Throws:
      Exception - on error
    • getFactoryMethod

      @Nullable default Method getFactoryMethod()
      Return the factory method that this supplier uses to create the instance, or null if it is not known or this supplier uses another means.
      Returns:
      the factory method used to create the instance, or null
    • andThen

      default <V> InstanceSupplier<V> andThen(org.springframework.util.function.ThrowingBiFunction<RegisteredBean,? super T,? extends V> after)
      Return a composed instance supplier that first obtains the instance from this supplier and then applies the after function to obtain the result.
      Type Parameters:
      V - the type of output of the after function, and of the composed function
      Parameters:
      after - the function to apply after the instance is obtained
      Returns:
      a composed instance supplier
    • using

      static <T> InstanceSupplier<T> using(org.springframework.util.function.ThrowingSupplier<T> supplier)
      Factory method to create an InstanceSupplier from a ThrowingSupplier.
      Type Parameters:
      T - the type of instance supplied by this supplier
      Parameters:
      supplier - the source supplier
      Returns:
      a new InstanceSupplier
    • using

      static <T> InstanceSupplier<T> using(@Nullable Method factoryMethod, org.springframework.util.function.ThrowingSupplier<T> supplier)
      Factory method to create an InstanceSupplier from a ThrowingSupplier.
      Type Parameters:
      T - the type of instance supplied by this supplier
      Parameters:
      factoryMethod - the factory method being used
      supplier - the source supplier
      Returns:
      a new InstanceSupplier
    • of

      static <T> InstanceSupplier<T> of(InstanceSupplier<T> instanceSupplier)
      Lambda friendly method that can be used to create an InstanceSupplier and add post processors in a single call. For example: InstanceSupplier.of(registeredBean -> ...).andThen(...).
      Type Parameters:
      T - the type of instance supplied by this supplier
      Parameters:
      instanceSupplier - the source instance supplier
      Returns:
      a new InstanceSupplier