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 Summary
Modifier and TypeMethodDescriptiondefault <U> BeanReference<? extends U> asSubTypeOf(Class<U> expectedType) Cast this reference into a reference whoseresolve(BeanResolver)method is is guaranteed to either fail or return an instance of the given type.static <T> BeanReference<T> Create aBeanReferencereferencing a bean by its type only.static <T> BeanReference<T> Create aBeanReferencereferencing a bean by type and name.static <T> BeanReference<T> of(Class<T> type, String name, BeanRetrieval retrieval) Create aBeanReferencereferencing a bean by type and name.static <T> BeanReference<T> of(Class<T> type, BeanRetrieval retrieval) Create aBeanReferencereferencing a bean by its type only.static <T> BeanReference<T> ofInstance(T instance) Create aBeanReferencereferencing a bean instance directly.static <T> BeanReference<T> static BeanReference<?> resolve(BeanResolver beanResolver) Resolve this reference into a bean using the given resolver.
-
Method Details
-
resolve
Resolve this reference into a bean using the given resolver.- Parameters:
beanResolver- A resolver to resolve this reference with.- Returns:
- The bean instance.
-
asSubTypeOf
Cast this reference into a reference whoseresolve(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
Create aBeanReferencereferencing 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
Create aBeanReferencereferencing 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. SeeBeanRetrieval.- Returns:
- The corresponding
BeanReference.
-
of
Create aBeanReferencereferencing 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
Create aBeanReferencereferencing 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. SeeBeanRetrieval.- Returns:
- The corresponding
BeanReference.
-
ofInstance
Create aBeanReferencereferencing a bean instance directly.- Type Parameters:
T- The bean type.- Parameters:
instance- The bean instance. Must not be null.- Returns:
- The corresponding
BeanReference.
-
parse
-
parse
-