private static void processKeyValue(Object instance, String propertyName, String kv) { String[] t = kv.split("="); if (t.length != 2) { // We must have a single key and a single value. throw ConversionException.couldNotTranslatePropertiesIntoObject(instance, propertyName, kv, null); } String methodName = "set" + t[0].trim(); // Stringified value to be set. Need to figure out it's type String value = t[1].trim(); List<Method> methods = getMethodsMatchingName(instance, methodName); MethodMatch match = null; try { match = getMethodMatchingParameter(methods, value); } catch (Exception e) { throw ConversionException.couldNotTranslatePropertiesIntoObject(instance, propertyName, kv, e); } if (match != null) { Method method = match.getMethod(); Object parsedValue = match.getParsedValue(); try { invokeMethod(method, instance, parsedValue); } catch (Exception e) { throw ConversionException.couldNotTranslatePropertiesIntoObject(instance, propertyName, kv, e); } } else { throw ConversionException.couldNotTranslatePropertiesIntoObject(instance, propertyName, kv, null); } }
private static void processKeyValue(Object instance, String propertyName, String kv) { String[] t = kv.split("="); if (t.length != 2) { // We must have a single key and a single value. throw ConversionException.couldNotTranslatePropertiesIntoObject(instance, propertyName, kv, null); } String methodName = "set" + t[0].trim(); // Stringified value to be set. Need to figure out it's type String value = t[1].trim(); List<Method> methods = getMethodsMatchingName(instance, methodName); MethodMatch match = null; try { match = getMethodMatchingParameter(methods, value); } catch (Exception e) { throw ConversionException.couldNotTranslatePropertiesIntoObject(instance, propertyName, kv, e); } if (match != null) { Method method = match.getMethod(); Object parsedValue = match.getParsedValue(); try { invokeMethod(method, instance, parsedValue); } catch (Exception e) { throw ConversionException.couldNotTranslatePropertiesIntoObject(instance, propertyName, kv, e); } } else { throw ConversionException.couldNotTranslatePropertiesIntoObject(instance, propertyName, kv, null); } }