Interface BeanUtil
- All Known Implementing Classes:
BeanUtilBean, BeanUtilUtil
public interface BeanUtil
Supreme utility for reading and writing bean properties. However, this one is the fastest available.
Although it provides various methods, the whole thing can be easily extended to match most needs.
BeanUtil supports:
- Nested properties: separated by a dot ('.')
- Indexed properties: arrays or Lists
- Simple properties: accessor or Map
Variants includes combinations of forced, declared and silent writing.
- Forced setting property tries to create destination property so it can be set correctly.
- Silent doesn't throw an exception if destination doesn't exist or if conversion fails.
- Declared includes only declared (public) properties.
This utility considers both bean property methods (set and get accessors), and bean fields. This is done because of several reasons: often there is no need for both set/get accessors, since bean logic requires just one functionality (e.g. just reading). In such case, other bean manipulation libraries still requires to have both accessors in order to set or get value. Another reason is that most common usage is to work with public accessors, and in that case private fields are ignored.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionextractThisReference(String propertyName) Returns the very first name chunk of the property.<T> TgetIndexProperty(Object bean, String property, int index) Returns value of indexed property.<T> TgetProperty(Object bean, String name) Returns value of bean's property.Class<?> getPropertyType(Object bean, String name) Returns property type.<T> TgetSimpleProperty(Object bean, String property) Reads simple property.booleanhasProperty(Object bean, String name) Returnstrueif bean has a property.booleanhasRootProperty(Object bean, String name) Returnstrueif bean has only a root property.booleanhasSimpleProperty(Object bean, String property) Returnstrueif simple property exist.voidsetIndexProperty(Object bean, String property, int index, Object value) Sets indexed property.voidsetProperty(Object bean, String name, Object value) Sets Java Bean property.voidsetSimpleProperty(Object bean, String property, Object value) Sets simple property.
-
Field Details
-
pojo
Default instance ofBeanUtilBean. -
declared
-
silent
-
forced
-
declaredSilent
-
declaredForced
-
declaredForcedSilent
-
forcedSilent
-
-
Method Details
-
setProperty
-
setIndexProperty
-
setSimpleProperty
-
getProperty
-
getIndexProperty
-
getSimpleProperty
-
hasProperty
-
hasRootProperty
-
hasSimpleProperty
-
getPropertyType
-
extractThisReference
-