Top Description Methods
org.springframework.beans.factory.support

public Interface InstanceSupplier<T>

extends ThrowingSupplier<T>
Known Direct Implementers
org.springframework.beans.factory.aot.BeanInstanceSupplier
Annotations
@FunctionalInterface
Type Parameters
<T>
the type of instance supplied by this supplier
Imports
java.lang.reflect.Method, java.util.function.Supplier, org.springframework.lang.Nullable, org.springframework.util.Assert, org.springframework.util.function.ThrowingBiFunction, .ThrowingSupplier

Specialized Supplier that can be set on a BeanDefinition when details about the registered bean are needed to supply the instance.
Authors
Phillip Webb, Stephane Nicoll
Since
6.0
See Also
RegisteredBean, org.springframework.beans.factory.aot.BeanInstanceSupplier

Method Summary

Modifier and TypeMethod and Description
public default <
the type of output of the after function, and of the composed function
V
>
InstanceSupplier<V>

Returns:

a composed instance supplier
andThen
(ThrowingBiFunction<RegisteredBean, ? super T, ? extends V>
the function to apply after the instance is obtained
after
)

Return a composed instance supplier that first obtains the instance from this supplier and then applies the after function to obtain the result.

public T

Returns:

the supplied instance
get
(RegisteredBean
the registered bean requesting the instance
registeredBean
)

Get the supplied instance.

public default Method

Returns:

the factory method used to create the instance, or null
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.

public default T
getWithException()

Implements org.springframework.util.function.ThrowingSupplier.getWithException.

Gets a result, possibly throwing a checked exception.

public static <
the type of instance supplied by this supplier
T
>
InstanceSupplier<T>

Returns:

a new InstanceSupplier
of
(InstanceSupplier<T>
the source instance supplier
instanceSupplier
)

Lambda friendly method that can be used to create an InstanceSupplier and add post processors in a single call.

public static <
the type of instance supplied by this supplier
T
>
InstanceSupplier<T>

Returns:

a new InstanceSupplier
using
(ThrowingSupplier<T>
the source supplier
supplier
)

Factory method to create an InstanceSupplier from a ThrowingSupplier.

public static <
the type of instance supplied by this supplier
T
>
InstanceSupplier<T>

Returns:

a new InstanceSupplier
using
(Method
the factory method being used
factoryMethod
,
ThrowingSupplier<T>
the source supplier
supplier
)

Factory method to create an InstanceSupplier from a ThrowingSupplier.

Inherited from org.springframework.util.function.ThrowingSupplier:
getgetofofthrowing

Method Detail

andThenback to summary
public default <V> InstanceSupplier<V> andThen(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.

Parameters
<V>
the type of output of the after function, and of the composed function
after:ThrowingBiFunction<RegisteredBean, ? super T, ? extends V>

the function to apply after the instance is obtained

Returns:InstanceSupplier<V>

a composed instance supplier

getback to summary
public T get(RegisteredBean registeredBean) throws Exception

Get the supplied instance.

Parameters
registeredBean:RegisteredBean

the registered bean requesting the instance

Returns:T

the supplied instance

Exceptions
Exception:
on error
getFactoryMethodback to summary
public 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:Method

the factory method used to create the instance, or null

Annotations
@Nullable
getWithExceptionback to summary
public default T getWithException()

Implements org.springframework.util.function.ThrowingSupplier.getWithException.

Doc from org.springframework.util.function.ThrowingSupplier.getWithException.

Gets a result, possibly throwing a checked exception.

Returns:T

a result

Annotations
@Override
ofback to summary
public 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(...).

Parameters
<T>
the type of instance supplied by this supplier
instanceSupplier:InstanceSupplier<T>

the source instance supplier

Returns:InstanceSupplier<T>

a new InstanceSupplier

usingback to summary
public static <T> InstanceSupplier<T> using(ThrowingSupplier<T> supplier)

Factory method to create an InstanceSupplier from a ThrowingSupplier.

Parameters
<T>
the type of instance supplied by this supplier
supplier:ThrowingSupplier<T>

the source supplier

Returns:InstanceSupplier<T>

a new InstanceSupplier

usingback to summary
public static <T> InstanceSupplier<T> using(Method factoryMethod, ThrowingSupplier<T> supplier)

Factory method to create an InstanceSupplier from a ThrowingSupplier.

Parameters
<T>
the type of instance supplied by this supplier
factoryMethod:Method

the factory method being used

supplier:ThrowingSupplier<T>

the source supplier

Returns:InstanceSupplier<T>

a new InstanceSupplier