I would like to copy the properties of an object to another, only if they are not null and exist in the target object.
I know BeanUtils.copyProperties
but it doesn t exactly suit the need.
What totally suit is the jquery.extend function. Is there an equivalent in the Java libraries/frameworks ? (or else I ll write my own...)
例如,目的地是用户,其来源是用户:
User UserSettings User
fisrtName="Rick" firstName=null fisrtName="Rick"
lastName="Dangerous" extends lastName="newLastName" gives lastName="newLastName"
nickName="RD" nickName="RD"
EDIT
最后,我写了我自己的方法,如果有人有兴趣见。