public interface BeanUtil
BeanUtil supports:
Variants includes combinations of forced, declared and silent writing.
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.
Modifier and Type | Field and Description |
---|---|
static BeanUtil |
declared |
static BeanUtil |
declaredForced |
static BeanUtil |
declaredForcedSilent |
static BeanUtil |
declaredSilent |
static BeanUtil |
forced |
static BeanUtil |
forcedSilent |
static BeanUtil |
pojo
Default instance of
BeanUtilBean . |
static BeanUtil |
silent |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
extractThisReference(java.lang.String propertyName)
Returns the very first name chunk of the property.
|
<T> T |
getIndexProperty(java.lang.Object bean,
java.lang.String property,
int index)
Returns value of indexed property.
|
<T> T |
getProperty(java.lang.Object bean,
java.lang.String name)
Returns value of bean's property.
|
java.lang.Class<?> |
getPropertyType(java.lang.Object bean,
java.lang.String name)
Returns property type.
|
<T> T |
getSimpleProperty(java.lang.Object bean,
java.lang.String property)
Reads simple property.
|
boolean |
hasProperty(java.lang.Object bean,
java.lang.String name)
Returns
true if bean has a property. |
boolean |
hasRootProperty(java.lang.Object bean,
java.lang.String name)
Returns
true if bean has only a root property. |
boolean |
hasSimpleProperty(java.lang.Object bean,
java.lang.String property)
Returns
true if simple property exist. |
void |
setIndexProperty(java.lang.Object bean,
java.lang.String property,
int index,
java.lang.Object value)
Sets indexed property.
|
void |
setProperty(java.lang.Object bean,
java.lang.String name,
java.lang.Object value)
Sets Java Bean property.
|
void |
setSimpleProperty(java.lang.Object bean,
java.lang.String property,
java.lang.Object value)
Sets simple property.
|
static final BeanUtil pojo
BeanUtilBean
.static final BeanUtil declared
static final BeanUtil silent
static final BeanUtil forced
static final BeanUtil declaredSilent
static final BeanUtil declaredForced
static final BeanUtil declaredForcedSilent
static final BeanUtil forcedSilent
void setProperty(java.lang.Object bean, java.lang.String name, java.lang.Object value)
bean
- Java POJO bean or a Mapname
- property namevalue
- property valuevoid setIndexProperty(java.lang.Object bean, java.lang.String property, int index, java.lang.Object value)
void setSimpleProperty(java.lang.Object bean, java.lang.String property, java.lang.Object value)
<T> T getProperty(java.lang.Object bean, java.lang.String name)
In silent mode, returning of null
is ambiguous: it may means that property name
is valid and property value is null
or that property name is invalid.
Using forced mode does not have any influence on the result.
<T> T getIndexProperty(java.lang.Object bean, java.lang.String property, int index)
<T> T getSimpleProperty(java.lang.Object bean, java.lang.String property)
boolean hasProperty(java.lang.Object bean, java.lang.String name)
true
if bean has a property.boolean hasRootProperty(java.lang.Object bean, java.lang.String name)
true
if bean has only a root property.
If yes, this means that property may be injected into the bean.
If not, bean does not contain the property.boolean hasSimpleProperty(java.lang.Object bean, java.lang.String property)
true
if simple property exist.java.lang.Class<?> getPropertyType(java.lang.Object bean, java.lang.String name)
java.lang.String extractThisReference(java.lang.String propertyName)
Copyright © 2003-present Jodd Team