Interface BeanSupplier<T>

  • All Superinterfaces:
    java.util.function.Supplier<T>
    All Known Implementing Classes:
    BeanSupplier.DefaultBeanSupplier

    public interface BeanSupplier<T>
    extends java.util.function.Supplier<T>
    This is BeanSupplier.
    Since:
    6.5.0
    • Field Detail

      • PROXY_BEAN_TOSTRING_PREFIX

        static final java.lang.String PROXY_BEAN_TOSTRING_PREFIX
        ToString() prefix.
        See Also:
        Constant Field Values
    • Method Detail

      • of

        static <T> BeanSupplier<T> of​(java.lang.Class<T> clazz)
        Create bean supplier for type.
        Type Parameters:
        T - the type parameter
        Parameters:
        clazz - the clazz
        Returns:
        the bean supplier
      • isProxy

        static boolean isProxy​(java.lang.Object result)
        Is proxy class?
        Parameters:
        result - the result
        Returns:
        the boolean
      • isNotProxy

        static boolean isNotProxy​(java.lang.Object result)
        Is not proxy class?
        Parameters:
        result - the result
        Returns:
        the boolean
      • get

        T get()
        Specified by:
        get in interface java.util.function.Supplier<T>
      • alwaysMatch

        default BeanSupplier<T> alwaysMatch()
        Always true condition.
        Returns:
        the bean supplier
      • neverMatch

        default BeanSupplier<T> neverMatch()
        Always false condition.
        Returns:
        the bean supplier
      • when

        BeanSupplier<T> when​(java.util.function.Supplier<java.lang.Boolean> conditionSupplier)
        Specify condition for bean supplier to create beans.
        Parameters:
        conditionSupplier - the condition supplier
        Returns:
        the bean supplier
      • when

        default BeanSupplier<T> when​(boolean rawValue)
        Specify condition for bean supplier to create beans.
        Parameters:
        rawValue - the raw value
        Returns:
        the bean supplier
      • ifExists

        default BeanSupplier<T> ifExists​(java.lang.String resource)
        Add condition to ensure given resource exist.
        Parameters:
        resource - the resource
        Returns:
        the bean supplier
      • and

        default BeanSupplier<T> and​(java.util.function.Supplier<java.lang.Boolean> conditionSupplier)
        Combine conditions together.
        Parameters:
        conditionSupplier - the condition supplier
        Returns:
        the bean supplier
      • supply

        BeanSupplier<T> supply​(java.util.function.Supplier<T> beanSupplier)
        Create the bean via a given supplier when condition passes.
        Parameters:
        beanSupplier - the bean supplier
        Returns:
        the bean supplier
      • otherwise

        BeanSupplier<T> otherwise​(java.util.function.Supplier<T> beanSupplier)
        Create the proxy bean via a given supplier when the condition fails.
        Parameters:
        beanSupplier - the bean supplier
        Returns:
        the bean supplier
      • otherwiseProxy

        BeanSupplier<T> otherwiseProxy()
        Create the proxy bean via a given supplier when the condition fails.
        Returns:
        the bean supplier