public interface BeanReference<T>
Modifier and Type | Method and Description |
---|---|
default <U> BeanReference<? extends U> |
asSubTypeOf(Class<U> expectedType)
Cast this reference into a reference whose
getBean(BeanProvider) method is is guaranteed to
either fail or return an instance of the given type. |
BeanHolder<T> |
getBean(BeanProvider beanProvider)
Get the bean this reference points to using the given provider.
|
static <T> BeanReference<T> |
of(Class<T> type)
Create a
BeanReference referencing a bean by its type only. |
static <T> BeanReference<T> |
of(Class<T> type,
String name)
Create a
BeanReference referencing a bean by type and name. |
static <T> BeanReference<T> |
ofInstance(T instance)
Create a
BeanReference referencing a bean instance directly. |
BeanHolder<T> getBean(BeanProvider beanProvider)
beanProvider
- A provider to get the bean from.default <U> BeanReference<? extends U> asSubTypeOf(Class<U> expectedType)
getBean(BeanProvider)
method is is guaranteed to
either fail or return an instance of the given type.U
- The expected bean type.expectedType
- The expected bean type.ClassCastException
- If this reference is certain to never return an instance of the given type.static <T> BeanReference<T> of(Class<T> type)
BeanReference
referencing a bean by its type only.type
- The bean type. Must not be null.BeanReference
.static <T> BeanReference<T> of(Class<T> type, String name)
BeanReference
referencing a bean by type and name.type
- The bean type. Must not be null.name
- The bean name. May be null or empty.BeanReference
.static <T> BeanReference<T> ofInstance(T instance)
BeanReference
referencing a bean instance directly.instance
- The bean instance. Must not be null.BeanReference
.Copyright © 2006-2019 Red Hat, Inc. and others. Licensed under the GNU Lesser General Public License (LGPL), version 2.1 or later.