Search in sources :

Example 1 with CachingIntrospector

use of jodd.introspector.CachingIntrospector in project jodd by oblac.

the class BeanPrefixTest method testFieldPrefix2.

@Test
public void testFieldPrefix2() {
    BeanUtilBean beanUtilBean = new BeanUtilBean();
    LifeBean lifeBean = new LifeBean();
    String bar = beanUtilBean.getProperty(lifeBean, "bar").toString();
    assertEquals("bar", bar);
    beanUtilBean.setIntrospector(new CachingIntrospector(true, true, true, new String[] { "_" }));
    bar = beanUtilBean.getProperty(lifeBean, "bar").toString();
    assertEquals("_bar", bar);
}
Also used : CachingIntrospector(jodd.introspector.CachingIntrospector) LifeBean(jodd.bean.data.LifeBean) Test(org.junit.Test)

Example 2 with CachingIntrospector

use of jodd.introspector.CachingIntrospector in project jodd by oblac.

the class BeanPrefixTest method testFieldPrefix1.

@Test
public void testFieldPrefix1() {
    LifeBean lifeBean = new LifeBean();
    String foo = BeanUtil.pojo.getProperty(lifeBean, "foo").toString();
    assertEquals("foo", foo);
    JoddIntrospector.introspector = new CachingIntrospector(true, true, true, new String[] { "_" });
    foo = BeanUtil.pojo.getProperty(lifeBean, "foo").toString();
    assertEquals("foo", foo);
    ClassDescriptor cd = JoddIntrospector.introspector.lookup(LifeBean.class);
    PropertyDescriptor[] pds = cd.getAllPropertyDescriptors();
    assertEquals(3, pds.length);
    assertEquals("bar", pds[0].getName());
    assertEquals("_bar", pds[0].getFieldDescriptor().getName());
    assertEquals("www", pds[2].getName());
    assertEquals(null, pds[2].getFieldDescriptor());
    JoddIntrospector.introspector = new CachingIntrospector();
}
Also used : CachingIntrospector(jodd.introspector.CachingIntrospector) ClassDescriptor(jodd.introspector.ClassDescriptor) PropertyDescriptor(jodd.introspector.PropertyDescriptor) LifeBean(jodd.bean.data.LifeBean) Test(org.junit.Test)

Example 3 with CachingIntrospector

use of jodd.introspector.CachingIntrospector in project jodd by oblac.

the class BeanPrefixTest method testFieldPrefix1withEmpty.

@Test
public void testFieldPrefix1withEmpty() {
    LifeBean lifeBean = new LifeBean();
    String foo = BeanUtil.pojo.getProperty(lifeBean, "foo").toString();
    assertEquals("foo", foo);
    JoddIntrospector.introspector = new CachingIntrospector(true, true, true, new String[] { "_", "" });
    foo = BeanUtil.pojo.getProperty(lifeBean, "foo").toString();
    assertEquals("foo", foo);
    ClassDescriptor cd = JoddIntrospector.introspector.lookup(LifeBean.class);
    PropertyDescriptor[] pds = cd.getAllPropertyDescriptors();
    assertEquals(3, pds.length);
    assertEquals("bar", pds[0].getName());
    assertEquals("_bar", pds[0].getFieldDescriptor().getName());
    assertEquals("www", pds[2].getName());
    assertEquals("www", pds[2].getFieldDescriptor().getName());
    JoddIntrospector.introspector = new CachingIntrospector();
}
Also used : CachingIntrospector(jodd.introspector.CachingIntrospector) ClassDescriptor(jodd.introspector.ClassDescriptor) PropertyDescriptor(jodd.introspector.PropertyDescriptor) LifeBean(jodd.bean.data.LifeBean) Test(org.junit.Test)

Aggregations

LifeBean (jodd.bean.data.LifeBean)3 CachingIntrospector (jodd.introspector.CachingIntrospector)3 Test (org.junit.Test)3 ClassDescriptor (jodd.introspector.ClassDescriptor)2 PropertyDescriptor (jodd.introspector.PropertyDescriptor)2