@Test public void testParse() { MyBean bean = new MyBean(); ArgumentsParser parser = new ArgumentsParser(bean); parser .parse(new String[] { "string='aaa'", "integer=1", "bool=true", "ch=\\u0097", "myEnum=AAA", "list=['aaa','bbb']", "file='aaa'" }); assertEquals("aaa", bean.getString()); assertEquals(new Integer(1), bean.getInteger()); assertTrue(bean.isBool()); assertEquals('a', bean.getCh()); assertEquals(MyEnum.AAA, bean.getMyEnum()); assertEquals(Arrays.asList("aaa", "bbb"), bean.getList()); assertEquals(new File("aaa"), bean.getFile()); }
public void parse(String[] args) { for (String arg : args) { int pos = arg.indexOf("="); if (pos < 0) { throw new IllegalArgumentException(arg); } String key = arg.substring(0, pos); String value = arg.substring(pos + 1, arg.length()); if (!beanDesc.hasPropertyDesc(key)) { continue; } PropertyDesc propertyDesc = beanDesc.getPropertyDesc(key); if (!propertyDesc.hasWriteMethod()) { continue; } ArgumentType<?> argumentType = ArgumentTypeRegistry .getArgumentType(propertyDesc); if (argumentType == null) { logger.log("WS2JDBCGEN0001", new Object[] { bean.getClass().getName(), propertyDesc.getPropertyName() }); continue; } Object propertyValue = argumentType.toObject(value); propertyDesc.setValue(bean, propertyValue); } }
ArgumentsParser { public void parse(String[] args) { for (String arg : args) { int pos = arg.indexOf("="); if (pos < 0) { throw new IllegalArgumentException(arg); } String key = arg.substring(0, pos); String value = arg.substring(pos + 1, arg.length()); if (!beanDesc.hasPropertyDesc(key)) { continue; } PropertyDesc propertyDesc = beanDesc.getPropertyDesc(key); if (!propertyDesc.hasWriteMethod()) { continue; } ArgumentType<?> argumentType = ArgumentTypeRegistry .getArgumentType(propertyDesc); if (argumentType == null) { logger.log("WS2JDBCGEN0001", new Object[] { bean.getClass().getName(), propertyDesc.getPropertyName() }); continue; } Object propertyValue = argumentType.toObject(value); propertyDesc.setValue(bean, propertyValue); } } }
ArgumentsParser { public void parse(String[] args) { for (String arg : args) { int pos = arg.indexOf("="); if (pos < 0) { throw new IllegalArgumentException(arg); } String key = arg.substring(0, pos); String value = arg.substring(pos + 1, arg.length()); if (!beanDesc.hasPropertyDesc(key)) { continue; } PropertyDesc propertyDesc = beanDesc.getPropertyDesc(key); if (!propertyDesc.hasWriteMethod()) { continue; } ArgumentType<?> argumentType = ArgumentTypeRegistry .getArgumentType(propertyDesc); if (argumentType == null) { logger.log("WS2JDBCGEN0001", new Object[] { bean.getClass().getName(), propertyDesc.getPropertyName() }); continue; } Object propertyValue = argumentType.toObject(value); propertyDesc.setValue(bean, propertyValue); } } ArgumentsParser(Object bean); }
ArgumentsParser { public void parse(String[] args) { for (String arg : args) { int pos = arg.indexOf("="); if (pos < 0) { throw new IllegalArgumentException(arg); } String key = arg.substring(0, pos); String value = arg.substring(pos + 1, arg.length()); if (!beanDesc.hasPropertyDesc(key)) { continue; } PropertyDesc propertyDesc = beanDesc.getPropertyDesc(key); if (!propertyDesc.hasWriteMethod()) { continue; } ArgumentType<?> argumentType = ArgumentTypeRegistry .getArgumentType(propertyDesc); if (argumentType == null) { logger.log("WS2JDBCGEN0001", new Object[] { bean.getClass().getName(), propertyDesc.getPropertyName() }); continue; } Object propertyValue = argumentType.toObject(value); propertyDesc.setValue(bean, propertyValue); } } ArgumentsParser(Object bean); void parse(String[] args); }
ArgumentsParser { public void parse(String[] args) { for (String arg : args) { int pos = arg.indexOf("="); if (pos < 0) { throw new IllegalArgumentException(arg); } String key = arg.substring(0, pos); String value = arg.substring(pos + 1, arg.length()); if (!beanDesc.hasPropertyDesc(key)) { continue; } PropertyDesc propertyDesc = beanDesc.getPropertyDesc(key); if (!propertyDesc.hasWriteMethod()) { continue; } ArgumentType<?> argumentType = ArgumentTypeRegistry .getArgumentType(propertyDesc); if (argumentType == null) { logger.log("WS2JDBCGEN0001", new Object[] { bean.getClass().getName(), propertyDesc.getPropertyName() }); continue; } Object propertyValue = argumentType.toObject(value); propertyDesc.setValue(bean, propertyValue); } } ArgumentsParser(Object bean); void parse(String[] args);  }