Interface BeanSupplier<T>


  • public interface BeanSupplier<T>
    A value supplier for use from within a given scope.
    • Method Detail

      • get

        T get​(Scope scope)
        Get the supplied value.
        Parameters:
        scope - the scope of the current resolution operation (not null)
        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 be null)
        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 be null)
        name - the bean name, or "" for any (must not be null)
        optional - true if the bean should be optional, or false if it should be required
        filter - the filter to apply to determine whether a given bean should be included (must not be null)
        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 be null)
        name - the bean name, or "" for any (must not be null)
        filter - the filter to apply to determine whether a given bean should be included (must not be null)
        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 be null)
        filter - the filter to apply to determine whether a given bean should be included (must not be null)
        Returns:
        the supplier (not null)