DataBinderTests.java 文件源码

java
阅读 26 收藏 0 点赞 0 评论 0

项目:class-guard 作者:
public void testCustomEditorWithOldValueAccess() {
    TestBean tb = new TestBean();
    DataBinder binder = new DataBinder(tb, "tb");

    binder.registerCustomEditor(String.class, null, new PropertyEditorSupport() {
        @Override
        public void setAsText(String text) throws IllegalArgumentException {
            if (getValue() == null || !text.equalsIgnoreCase(getValue().toString())) {
                setValue(text);
            }
        }
    });

    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.add("name", "value");
    binder.bind(pvs);
    assertEquals("value", tb.getName());

    pvs = new MutablePropertyValues();
    pvs.add("name", "vaLue");
    binder.bind(pvs);
    assertEquals("value", tb.getName());
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号