Search in sources :

Example 1 with DataRange

use of org.sagacity.sqltoy.demo.vo.DataRange in project sagacity-sqltoy by chenrenfei.

the class BeanUtilTest method testMultLevelMapListReflect.

@Test
public void testMultLevelMapListReflect() {
    StaffInfoVO staff = new StaffInfoVO();
    staff.setEmail("zhongxuchen@gmail.com");
    staff.setStaffId("S001");
    DataRange dataRange = new DataRange();
    dataRange.setBeginDate(DateUtil.getDate("2020-10-01"));
    dataRange.setEndDate(LocalDate.now());
    staff.setDataRange(dataRange);
    HashMap params = new HashMap();
    params.put("companyId", "C0001");
    params.put("companyName", "xxx企业集团");
    staff.setParams(params);
    Map map = new HashMap();
    map.put("staff", staff);
    List<Map> listMap = new ArrayList<Map>();
    listMap.add(map);
    List result = null;
    try {
        result = BeanUtil.reflectBeansToList(listMap, new String[] { "staff.staffid", "staff.email", "staff.dataRange.beginDate", "staff.dataRange.enddate", "staff.params.companyId", "staff.params.companyName" }, null);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    for (Object tmp : result) {
        System.err.println(tmp);
    }
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) StaffInfoVO(org.sagacity.sqltoy.demo.vo.StaffInfoVO) DataRange(org.sagacity.sqltoy.demo.vo.DataRange) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) IgnoreKeyCaseMap(org.sagacity.sqltoy.model.IgnoreKeyCaseMap) IgnoreCaseLinkedMap(org.sagacity.sqltoy.model.IgnoreCaseLinkedMap) Map(java.util.Map) Test(org.junit.jupiter.api.Test)

Example 2 with DataRange

use of org.sagacity.sqltoy.demo.vo.DataRange in project sagacity-sqltoy by chenrenfei.

the class BeanUtilTest method testMultLevelReflect.

// 测试多级反射
@Test
public void testMultLevelReflect() {
    StaffInfoVO staff = new StaffInfoVO();
    staff.setEmail("zhongxuchen@gmail.com");
    staff.setStaffId("S001");
    DataRange dataRange = new DataRange();
    dataRange.setBeginDate(DateUtil.getDate("2020-10-01"));
    dataRange.setEndDate(LocalDate.now());
    staff.setDataRange(dataRange);
    HashMap params = new HashMap();
    params.put("companyId", "C0001");
    params.put("companyName", "xxx企业集团");
    staff.setParams(params);
    Object[] result = BeanUtil.reflectBeanToAry(staff, new String[] { "staffId", "email", "dataRange.beginDate", "dataRange.enddate", "params.companyId", "params.companyName" }, null, null);
    for (Object tmp : result) {
        System.err.println(tmp);
    }
}
Also used : HashMap(java.util.HashMap) StaffInfoVO(org.sagacity.sqltoy.demo.vo.StaffInfoVO) DataRange(org.sagacity.sqltoy.demo.vo.DataRange) Test(org.junit.jupiter.api.Test)

Example 3 with DataRange

use of org.sagacity.sqltoy.demo.vo.DataRange in project sagacity-sqltoy by chenrenfei.

the class BeanUtilTest method testMultLevelMapReflect.

@Test
public void testMultLevelMapReflect() {
    StaffInfoVO staff = new StaffInfoVO();
    staff.setEmail("zhongxuchen@gmail.com");
    staff.setStaffId("S001");
    DataRange dataRange = new DataRange();
    dataRange.setBeginDate(DateUtil.getDate("2020-10-01"));
    dataRange.setEndDate(LocalDate.now());
    staff.setDataRange(dataRange);
    HashMap params = new HashMap();
    params.put("companyId", "C0001");
    params.put("companyName", "xxx企业集团");
    staff.setParams(params);
    Map map = new IgnoreKeyCaseMap();
    map.put("staff", staff);
    Object[] result = BeanUtil.reflectBeanToAry(map, new String[] { "staff.staffid", "staff.email", "staff.dataRange.beginDate", "staff.dataRange.enddate", "staff.params.companyId", "staff.params.companyName" }, null, null);
    for (Object tmp : result) {
        System.err.println(tmp);
    }
}
Also used : HashMap(java.util.HashMap) StaffInfoVO(org.sagacity.sqltoy.demo.vo.StaffInfoVO) DataRange(org.sagacity.sqltoy.demo.vo.DataRange) HashMap(java.util.HashMap) IgnoreKeyCaseMap(org.sagacity.sqltoy.model.IgnoreKeyCaseMap) IgnoreCaseLinkedMap(org.sagacity.sqltoy.model.IgnoreCaseLinkedMap) Map(java.util.Map) IgnoreKeyCaseMap(org.sagacity.sqltoy.model.IgnoreKeyCaseMap) Test(org.junit.jupiter.api.Test)

Aggregations

HashMap (java.util.HashMap)3 Test (org.junit.jupiter.api.Test)3 DataRange (org.sagacity.sqltoy.demo.vo.DataRange)3 StaffInfoVO (org.sagacity.sqltoy.demo.vo.StaffInfoVO)3 Map (java.util.Map)2 IgnoreCaseLinkedMap (org.sagacity.sqltoy.model.IgnoreCaseLinkedMap)2 IgnoreKeyCaseMap (org.sagacity.sqltoy.model.IgnoreKeyCaseMap)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1