Package io.smallrye.beanbag
Interface BeanSupplier<T>
-
public interface BeanSupplier<T>A value supplier for use from within a given scope.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description Tget(Scope scope)Get the supplied value.static <T> BeanSupplier<T>of(T instance)Get a bean supplier which always returns the given value.static <T> BeanSupplier<T>resolving(Class<T> type, String name, boolean optional, DependencyFilter filter)Get a bean supplier whose value is the result of resolution of a bean with the given parameters.static <T> BeanSupplier<List<T>>resolvingAll(Class<T> type, String name, DependencyFilter filter)Get a bean supplier whose value is a list representing the result of resolving all the beans with the given parameters.static <T> BeanSupplier<Map<String,T>>resolvingAllByName(Class<T> type, DependencyFilter filter)Get a bean supplier whose value is a map representing the result of resolving all the beans with the given parameters.default <U> BeanSupplier<U>transform(Function<T,U> function)Get a bean supplier which applies the given transformation function to the result of this supplier.
-
-
-
Method Detail
-
get
T get(Scope scope)
Get the supplied value.- Parameters:
scope- the scope of the current resolution operation (notnull)- Returns:
- the (possibly
null) resolved value
-
of
static <T> BeanSupplier<T> of(T instance)
Get a bean supplier which always returns the given value.- Type Parameters:
T- the value type- Parameters:
instance- the value to return- Returns:
- the value that was given
-
transform
default <U> BeanSupplier<U> transform(Function<T,U> function)
Get a bean supplier which applies the given transformation function to the result of this supplier.- Type Parameters:
U- the transformed value type- Parameters:
function- the transformation function (must not benull)- Returns:
- the transformed supplier (not
null)
-
resolving
static <T> BeanSupplier<T> resolving(Class<T> type, String name, boolean optional, DependencyFilter filter)
Get a bean supplier whose value is the result of resolution of a bean with the given parameters.- Type Parameters:
T- the bean type- Parameters:
type- the bean type class (must not benull)name- the bean name, or""for any (must not benull)optional-trueif the bean should be optional, orfalseif it should be requiredfilter- the filter to apply to determine whether a given bean should be included (must not benull)- Returns:
- the supplier (not
null)
-
resolvingAll
static <T> BeanSupplier<List<T>> resolvingAll(Class<T> type, String name, DependencyFilter filter)
Get a bean supplier whose value is a list representing the result of resolving all the beans with the given parameters.- Type Parameters:
T- the bean type- Parameters:
type- the bean type class (must not benull)name- the bean name, or""for any (must not benull)filter- the filter to apply to determine whether a given bean should be included (must not benull)- Returns:
- the supplier (not
null)
-
resolvingAllByName
static <T> BeanSupplier<Map<String,T>> resolvingAllByName(Class<T> type, DependencyFilter filter)
Get a bean supplier whose value is a map representing the result of resolving all the beans with the given parameters. The key of the map is the bean name, and the value is the bean instance.- Type Parameters:
T- the bean type- Parameters:
type- the bean type class (must not benull)filter- the filter to apply to determine whether a given bean should be included (must not benull)- Returns:
- the supplier (not
null)
-
-