Interface BeanReference<T>

Type Parameters:
T - The type of the referenced bean.

public interface BeanReference<T>
A reference to a bean, allowing the retrieval of that bean when passed a BeanResolver.
  • Method Details

    • resolve

      BeanHolder<T> resolve(BeanResolver beanResolver)
      Resolve this reference into a bean using the given resolver.
      Parameters:
      beanResolver - A resolver to resolve this reference with.
      Returns:
      The bean instance.
    • asSubTypeOf

      default <U> BeanReference<? extends U> asSubTypeOf(Class<U> expectedType)
      Cast this reference into a reference whose resolve(BeanResolver) method is is guaranteed to either fail or return an instance of the given type.
      Type Parameters:
      U - The expected bean type.
      Parameters:
      expectedType - The expected bean type.
      Returns:
      A bean reference.
      Throws:
      ClassCastException - If this reference is certain to never return an instance of the given type.
    • of

      static <T> BeanReference<T> of(Class<T> type)
      Create a BeanReference referencing a bean by its type only.
      Type Parameters:
      T - The bean type.
      Parameters:
      type - The bean type. Must not be null.
      Returns:
      The corresponding BeanReference.
    • of

      static <T> BeanReference<T> of(Class<T> type, BeanRetrieval retrieval)
      Create a BeanReference referencing a bean by its type only.
      Type Parameters:
      T - The bean type.
      Parameters:
      type - The bean type. Must not be null.
      retrieval - How to retrieve the bean. See BeanRetrieval.
      Returns:
      The corresponding BeanReference.
    • of

      static <T> BeanReference<T> of(Class<T> type, String name)
      Create a BeanReference referencing a bean by type and name.
      Type Parameters:
      T - The bean type.
      Parameters:
      type - The bean type. Must not be null.
      name - The bean name. May be null or empty.
      Returns:
      The corresponding BeanReference.
    • of

      static <T> BeanReference<T> of(Class<T> type, String name, BeanRetrieval retrieval)
      Create a BeanReference referencing a bean by type and name.
      Type Parameters:
      T - The bean type.
      Parameters:
      type - The bean type. Must not be null.
      name - The bean name. May be null or empty.
      retrieval - How to retrieve the bean. See BeanRetrieval.
      Returns:
      The corresponding BeanReference.
    • ofInstance

      static <T> BeanReference<T> ofInstance(T instance)
      Create a BeanReference referencing a bean instance directly.
      Type Parameters:
      T - The bean type.
      Parameters:
      instance - The bean instance. Must not be null.
      Returns:
      The corresponding BeanReference.
    • parse

      static BeanReference<?> parse(String value)
    • parse

      static <T> BeanReference<T> parse(Class<T> expectedType, String value)