本文整理了Java中jodd.bean.BeanUtil.getPropertyType()
方法的一些代码示例,展示了BeanUtil.getPropertyType()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BeanUtil.getPropertyType()
方法的具体详情如下:
包路径:jodd.bean.BeanUtil
类名称:BeanUtil
方法名:getPropertyType
[英]Returns property type.
[中]返回属性类型。
代码示例来源:origin: oblac/jodd
Class hintPropertyType = BeanUtil.pojo.getPropertyType(value, hintPropertyName);
代码示例来源:origin: oblac/jodd
Class type = BeanUtil.declared.getPropertyType(result[currentResult], propertyName);
if (type != null) {
代码示例来源:origin: oblac/jodd
@Test
void testSetPropertyMath() {
FooBean2 fb = new FooBean2();
String propName = "fooBigDecimal";
assertEquals(BigDecimal.class, BeanUtil.pojo.getPropertyType(fb, propName));
BeanUtil.pojo.setProperty(fb, propName, new BigDecimal("1.2"));
assertEquals(1.2, fb.getFooBigDecimal().doubleValue(), 0.0005);
}
代码示例来源:origin: oblac/jodd
@Test
void testMap2() {
Map<String, String> m = new HashMap<>();
m.put("dd.dd", "value");
m.put("dd", "value2");
Map<String, Object> m2 = new HashMap<>();
m2.put("map", m);
FooBean fb = new FooBean();
fb.setFooMap(m);
assertEquals(Object.class, BeanUtil.declared.getPropertyType(fb, "fooMap[dd]"));
assertEquals("value2", BeanUtil.pojo.getProperty(fb, "fooMap[dd]"));
assertEquals("value2", BeanUtil.pojo.getProperty(m2, "map[dd]"));
assertEquals("value", BeanUtil.pojo.getProperty(fb, "fooMap[dd.dd]"));
assertEquals(Object.class, BeanUtil.declared.getPropertyType(fb, "fooMap[dd.dd]"));
assertEquals("value", BeanUtil.pojo.getProperty(m2, "map[dd.dd]"));
}
代码示例来源:origin: oblac/jodd
@Test
void testSetPropertySql() {
FooBean2 fb = new FooBean2();
String propName = "fooTimestamp";
//noinspection deprecation
Timestamp ts = new Timestamp(101, 0, 17, 1, 2, 3, 4);
assertEquals(Timestamp.class, BeanUtil.pojo.getPropertyType(fb, propName));
BeanUtil.pojo.setProperty(fb, propName, ts);
assertEquals("2001-01-17 01:02:03.000000004", fb.getFooTimestamp().toString());
propName = "fooTime";
//noinspection deprecation
Time t = new Time(17, 13, 15);
BeanUtil.pojo.setProperty(fb, propName, t);
assertEquals("17:13:15", fb.getFooTime().toString());
propName = "fooDate";
//noinspection deprecation
Date d = new Date(101, 1, 17);
assertEquals(Date.class, BeanUtil.pojo.getPropertyType(fb, propName));
BeanUtil.pojo.setProperty(fb, propName, d);
assertEquals("2001-02-17", fb.getFooDate().toString());
}
代码示例来源:origin: oblac/jodd
@Test
void testMap() {
Cbean cbean = new Cbean();
Abean abean = cbean.getBbean().getAbean();
assertNull(BeanUtil.declared.getPropertyType(abean, "mval"));
BeanUtil.pojo.setProperty(abean, "mval", new Integer(173));
BeanUtil.pojo.setProperty(abean, "mval2", new Integer(1));
assertEquals((abean.get("mval")).intValue(), 173);
assertEquals(173, ((Integer) BeanUtil.pojo.getProperty(abean, "mval")).intValue());
assertEquals(1, ((Integer) BeanUtil.pojo.getProperty(abean, "mval2")).intValue());
assertTrue(BeanUtil.declared.hasProperty(cbean, "bbean.abean.mval"));
assertTrue(BeanUtil.declared.hasRootProperty(cbean, "bbean.abean.mval"));
BeanUtil.pojo.setProperty(cbean, "bbean.abean.mval", new Integer(3));
assertEquals(3, ((Integer) BeanUtil.pojo.getProperty(abean, "mval")).intValue());
assertEquals(3, ((Integer) BeanUtil.pojo.getProperty(cbean, "bbean.abean.mval")).intValue());
HashMap map = new HashMap();
BeanUtil.pojo.setProperty(map, "val1", new Integer(173));
assertEquals(173, ((Integer) map.get("val1")).intValue());
Integer i = BeanUtil.pojo.getProperty(map, "val1");
assertEquals(173, i.intValue());
}
代码示例来源:origin: oblac/jodd
assertEquals(String.class, BeanUtil.declared.getPropertyType(gig, "listOfStrings[1]"));
BeanUtil.forced.setProperty(gig, "listOfStrings[1]", "string");
assertNull(gig.getListOfStrings().get(0));
assertEquals(MutableInteger.class, BeanUtil.declared.getPropertyType(gig, "listOfIntegers[1]"));
BeanUtil.forced.setProperty(gig, "listOfIntegers[1]", Integer.valueOf(1));
assertNull(gig.getListOfIntegers().get(0));
assertEquals(MutableInteger.class, BeanUtil.declared.getPropertyType(gig, "listOfIntegers[3]"));
BeanUtil.forced.setProperty(gig, "listOfIntegers[3]", "3");
assertNull(gig.getListOfIntegers().get(0));
assertNull(BeanUtil.declared.getPropertyType(gig, "listOfAbeans[1].fooProp")); // [1] doesnt exist yet
BeanUtil.forced.setProperty(gig, "listOfAbeans[1].fooProp", "xxx");
assertEquals(String.class, BeanUtil.declared.getPropertyType(gig, "listOfAbeans[1].fooProp"));
assertNull(gig.getListOfAbeans().get(0));
assertEquals("xxx", gig.getListOfAbeans().get(1).getFooProp());
assertEquals(2, gig.getListOfAbeans().size());
assertEquals(Integer.class, BeanUtil.declared.getPropertyType(gig, "mapOfIntegers[kkk]"));
BeanUtil.forced.setProperty(gig, "mapOfIntegers[kkk]", "173");
assertEquals(173, gig.getMapOfIntegers().get("kkk").intValue());
assertEquals(1, gig.getMapOfIntegers().size());
assertEquals(Abean.class, BeanUtil.declared.getPropertyType(gig, "mapOfAbeans[kkk]"));
BeanUtil.forced.setProperty(gig, "mapOfAbeans[kkk].fooProp", "zzz");
assertEquals("zzz", gig.getMapOfAbeans().get("kkk").getFooProp());
代码示例来源:origin: oblac/jodd
assertEquals(Integer.class, BeanUtil.pojo.getPropertyType(fb, "fooInteger"));
assertEquals(int.class, BeanUtil.pojo.getPropertyType(fb, "fooint"));
assertFalse(BeanUtil.pojo.hasProperty(fb, "fooint-xxx"));
assertNull(BeanUtil.pojo.getPropertyType(fb, "fooint-xxx"));
assertEquals(Byte.class, BeanUtil.pojo.getPropertyType(fb, "fooByte"));
assertEquals(new Byte((byte) 0), BeanUtil.forced.getSimpleProperty(fb, "fooByte"));
assertEquals(Map.class, BeanUtil.pojo.getPropertyType(fb, "fooMap"));
assertNull(BeanUtil.pojo.getSimpleProperty(fb, "fooMap"));
assertEquals(List.class, BeanUtil.pojo.getPropertyType(fb, "fooList"));
assertNull(BeanUtil.pojo.getSimpleProperty(fb, "fooList"));
assertEquals(String[].class, BeanUtil.pojo.getPropertyType(fb, "fooStringA"));
assertNull(BeanUtil.pojo.getSimpleProperty(fb, "fooStringA"));
String[] tmp = new String[10];
assertEquals(String[].class, BeanUtil.pojo.getPropertyType(fb, "fooStringA"));
assertNull(BeanUtil.pojo.getSimpleProperty(fb, "fooStringA"));
代码示例来源:origin: oblac/jodd
assertEquals(String.class, BeanUtil.declared.getPropertyType(fb, "fooStringA[0]"));
try {
BeanUtil.forced.getIndexProperty(fb, "fooStringA", 0);
assertEquals(String.class, BeanUtil.declared.getPropertyType(fb, "fooStringA[7]"));
try {
BeanUtil.pojo.setIndexProperty(fb, "fooStringA", 7, "xxx");
assertEquals(String.class, BeanUtil.declared.getPropertyType(fb, "fooStringA[40]"));
assertEquals(String[].class, BeanUtil.declared.getPropertyType(fb, "fooStringA"));
assertEquals(String.class, BeanUtil.declared.getPropertyType(fb, "fooStringA[40]"));
assertEquals("zzz", fb.getFooStringA()[40]);
assertEquals(41, fb.getFooStringA().length);
assertEquals(String.class, BeanUtil.declared.getPropertyType(fb, "fooStringA[43]"));
BeanUtil.forced.setIndexProperty(fb, "fooStringA", 43, null);
assertTrue(BeanUtil.declared.hasProperty(fb, "fooStringA[43]"));
assertEquals(String.class, BeanUtil.declared.getPropertyType(fb, "fooStringA[43]"));
assertNull(fb.getFooStringA()[43]);
assertEquals(44, fb.getFooStringA().length);
assertEquals(String.class, BeanUtil.declared.getPropertyType(fb, "fooStringA[43]"));
BeanUtil.forced.setIndexProperty(fb, "fooStringA", 7, "ccc");
assertEquals("ccc", fb.getFooStringA()[7]);
assertEquals(Object.class, BeanUtil.declared.getPropertyType(fb, "fooList[1]"));
try {
BeanUtil.forced.getIndexProperty(fb, "fooList", 1);
代码示例来源:origin: oblac/jodd
assertNull(BeanUtil.pojo.getPropertyType(fb, "fooInteger"));
assertEquals(Integer.class, BeanUtil.declared.getPropertyType(fb, "fooInteger"));
代码示例来源:origin: oblac/jodd
@Test
void testNested() {
Cbean cbean = new Cbean();
String value = "testnest";
String value2 = "nesttest";
assertEquals(String.class, BeanUtil.declared.getPropertyType(cbean, "bbean.abean.fooProp"));
assertTrue(BeanUtil.declared.hasProperty(cbean, "bbean.abean.fooProp"));
assertTrue(BeanUtil.declared.hasRootProperty(cbean, "bbean.abean.fooProp"));
BeanUtil.pojo.setProperty(cbean, "bbean.abean.fooProp", value);
assertEquals(value, BeanUtil.pojo.getProperty(cbean, "bbean.abean.fooProp"));
Bbean bbean = BeanUtil.pojo.getProperty(cbean, "bbean");
assertTrue(BeanUtil.declared.hasProperty(bbean, "abean.fooProp"));
assertTrue(BeanUtil.declared.hasRootProperty(bbean, "abean.fooProp"));
assertEquals(value, BeanUtil.pojo.getProperty(bbean, "abean.fooProp"));
Abean abean = BeanUtil.pojo.getProperty(bbean, "abean");
assertEquals(value, BeanUtil.pojo.getProperty(abean, "fooProp"));
BeanUtil.pojo.setProperty(bbean, "abean.fooProp", value2);
assertEquals(value2, BeanUtil.pojo.getProperty(bbean, "abean.fooProp"));
}
代码示例来源:origin: org.jodd/jodd-db
Class hintPropertyType = BeanUtil.pojo.getPropertyType(value, hintPropertyName);
代码示例来源:origin: org.jodd/jodd-db
Class type = BeanUtil.declared.getPropertyType(result[currentResult], propertyName);
if (type != null) {
内容来源于网络,如有侵权,请联系作者删除!