@Test public void testParse_nullOrDefaultValue() { MyBean bean = new MyBean(); ArgumentsParser parser = new ArgumentsParser(bean); parser.parse(new String[] { "string=", "integer=", "bool=", "ch=\\u0000", "myEnum=", "list=", "file=" }); assertNull(bean.getString()); assertNull(bean.getInteger()); assertFalse(bean.isBool()); assertEquals('\u0000', bean.getCh()); assertNull(bean.getMyEnum()); assertNull(bean.getList()); assertNull(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);  }