Package io.micronaut.core.beans
Interface BeanWrapper<T>
- Type Parameters:
T- The bean type.
- All Superinterfaces:
AnnotationMetadataProvider,AnnotationSource
Wraps a bean allowing to read and write its properties via an underlying
BeanIntrospection.- Since:
- 1.1
- Author:
- graemerocher
-
Field Summary
Fields inherited from interface io.micronaut.core.annotation.AnnotationSource
EMPTY -
Method Summary
Modifier and TypeMethodDescriptionstatic <T2> Optional<BeanWrapper<T2>> findWrapper(Class<T2> type, T2 bean) Obtain a bean wrapper for the given bean.static <T2> Optional<BeanWrapper<T2>> findWrapper(T2 bean) Obtain a bean wrapper for the given bean.getBean()default Collection<BeanProperty<T, Object>> The properties.default <P> Optional<P> getProperty(String name, ArgumentConversionContext<P> context) Get the property of the given name and type.default <P> Optional<P> getProperty(String name, Argument<P> type) Get the property of the given name and type.default <P> Optional<P> getProperty(String name, Class<P> type) Get the property of the given name and type.default String[]The property names.default <P> PgetRequiredProperty(String name, ArgumentConversionContext<P> context) Get the property value of the given type or throw an exception if it is unobtainable.default <P> PgetRequiredProperty(String name, Argument<P> argument) Get the property value of the given type or throw an exception if it is unobtainable.default <P> PgetRequiredProperty(String name, Class<P> type) Get the property value of the given type or throw an exception if it is unobtainable.static <T2> BeanWrapper<T2> getWrapper(Class<T2> type, T2 bean) Obtain a bean wrapper for the given bean.static <T2> BeanWrapper<T2> getWrapper(T2 bean) Obtain a bean wrapper for the given bean.default BeanWrapper<T> setProperty(String name, @Nullable Object value) Sets a property of the given name to the given value.Methods inherited from interface io.micronaut.core.annotation.AnnotationMetadataProvider
findAnnotation, findAnnotation, findDeclaredAnnotation, findDeclaredAnnotation, getAnnotationMetadata, getTargetAnnotationMetadata, isAnnotationPresent, isDeclaredAnnotationPresent, synthesize, synthesizeAll, synthesizeAnnotationsByType, synthesizeDeclared, synthesizeDeclared, synthesizeDeclaredAnnotationsByTypeMethods inherited from interface io.micronaut.core.annotation.AnnotationSource
getAnnotation, getAnnotation, getDeclaredAnnotation, getDeclaredAnnotation, isAnnotationPresent, isDeclaredAnnotationPresent, synthesize, synthesizeDeclared
-
Method Details
-
getIntrospection
BeanIntrospection<T> getIntrospection()- Returns:
- The introspection.
-
getBean
T getBean()- Returns:
- The bean;
-
getPropertyNames
The property names.- Returns:
- The property names
-
getBeanProperties
The properties.- Returns:
- The properties
-
getRequiredProperty
Get the property value of the given type or throw an exception if it is unobtainable.- Type Parameters:
P- The property generic type- Parameters:
name- The nametype- The type- Returns:
- The property value
- Throws:
IntrospectionException- if no property existsConversionErrorException- if the property cannot be converted to the given type
-
getRequiredProperty
Get the property value of the given type or throw an exception if it is unobtainable.- Type Parameters:
P- The property generic type- Parameters:
name- The nameargument- The argument type- Returns:
- The property value
- Throws:
IntrospectionException- if no property existsConversionErrorException- if the property cannot be converted to the given type
-
getRequiredProperty
Get the property value of the given type or throw an exception if it is unobtainable.- Type Parameters:
P- The property generic type- Parameters:
name- The namecontext- The type- Returns:
- The property value
- Throws:
IntrospectionException- if no property existsConversionErrorException- if the property cannot be converted to the given type
-
getProperty
Get the property of the given name and type.- Type Parameters:
P- The required generic type- Parameters:
name- The nametype- The required type- Returns:
- The property if found and can be converted to the given type
-
getProperty
Get the property of the given name and type.- Type Parameters:
P- The required generic type- Parameters:
name- The nametype- The required type- Returns:
- The property if found and can be converted to the given type
-
getProperty
Get the property of the given name and type.- Type Parameters:
P- The required generic type- Parameters:
name- The namecontext- The conversion context- Returns:
- The property if found and can be converted to the given type
-
setProperty
Sets a property of the given name to the given value.- Parameters:
name- The namevalue- The value- Returns:
- This wrapper
- Throws:
ConversionErrorException- if the value cannot be converted to the underlying property type.
-
getWrapper
Obtain a bean wrapper for the given bean.- Type Parameters:
T2- The bean type- Parameters:
bean- The bean- Returns:
- The wrapper
- Throws:
IntrospectionException- If the wrapper cannot be created
-
findWrapper
Obtain a bean wrapper for the given bean.- Type Parameters:
T2- The bean type- Parameters:
bean- The bean- Returns:
- The wrapper
- Throws:
IntrospectionException- If the wrapper cannot be created
-
findWrapper
Obtain a bean wrapper for the given bean.- Type Parameters:
T2- The bean type- Parameters:
type- the typebean- The bean- Returns:
- The wrapper
- Throws:
IntrospectionException- If the wrapper cannot be created
-
getWrapper
Obtain a bean wrapper for the given bean.- Type Parameters:
T2- The bean type- Parameters:
type- the typebean- The bean- Returns:
- The wrapper
- Throws:
IntrospectionException- If the wrapper cannot be created
-