Close

Spring Framework - PropertyAccessorFactory Examples

Spring Framework 

Creating BeanWrapper using PropertyAccessorFactory

package com.logicbig.example.propertyacessorfactory;

import com.logicbig.example.TestBean;
import org.springframework.beans.BeanWrapper;
import org.springframework.beans.PropertyAccessorFactory;

public class PropertyAccessorFactoryExample {

public static void main (String[] args) {
BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(new TestBean());
bw.setPropertyValue("aString", "anotherString");
System.out.println(bw.getWrappedInstance());
}
}

Output

TestBean{aString='anotherString', anInt=5, date=Mon May 01 16:08:01 CDT 2017}
Original Post




See Also