protected void applyProperty(Object object, String propertyName, String stringValue) { Object value; if (NULL_VALUE_TOKEN.equals(stringValue)) { value = null; } else if (EMPTY_STRING_VALUE_TOKEN.equals(stringValue)) { value = StringUtils.EMPTY_STRING; } else if (isIndexedPropertyAssignment(propertyName)) { String checked = checkForNullOrEmptyLiteral(stringValue); value = resolveValue(checked); } else if (isTypedProperty(object, propertyName, Set.class)) { value = toSet(stringValue); } else if (isTypedProperty(object, propertyName, Map.class)) { value = toMap(stringValue); } else if (isTypedProperty(object, propertyName, List.class)) { value = toList(stringValue); } else if (isTypedProperty(object, propertyName, Collection.class)) { value = toCollection(stringValue); } else if (isTypedProperty(object, propertyName, byte[].class)) { value = toBytes(stringValue); } else if (isTypedProperty(object, propertyName, ByteSource.class)) { byte[] bytes = toBytes(stringValue); value = ByteSource.Util.bytes(bytes); } else { String checked = checkForNullOrEmptyLiteral(stringValue); value = resolveValue(checked); } applyProperty(object, propertyName, value); }
protected void applyProperty(Object object, String propertyName, String stringValue) { Object value; if (isTypedProperty(object, propertyName, Set.class)) { value = toSet(stringValue); } else if (isTypedProperty(object, propertyName, Map.class)) { value = toMap(stringValue); } else if (isTypedProperty(object, propertyName, List.class) || isTypedProperty(object, propertyName, Collection.class)) { value = toList(stringValue); } else if (isTypedProperty(object, propertyName, byte[].class)) { value = toBytes(stringValue); } else { value = resolveValue(stringValue); } try { if (log.isTraceEnabled()) { log.trace("Applying property [{}] value [{}] on object of type [{}]", new Object[]{propertyName, value, object.getClass().getName()}); } BeanUtils.setProperty(object, propertyName, value); } catch (Exception e) { String msg = "Unable to set property '" + propertyName + "' with value [" + stringValue + "] on object " + "of type " + (object != null ? object.getClass().getName() : null) + ". If " + "'" + stringValue + "' is a reference to another (previously defined) object, prefix it with " + "'" + OBJECT_REFERENCE_BEGIN_TOKEN + "' to indicate that the referenced " + "object should be used as the actual value. " + "For example, " + OBJECT_REFERENCE_BEGIN_TOKEN + stringValue; throw new ConfigurationException(msg, e); } }
protected void applyProperty(Object object, String propertyName, String stringValue) { Object value; if (NULL_VALUE_TOKEN.equals(stringValue)) { value = null; } else if (EMPTY_STRING_VALUE_TOKEN.equals(stringValue)) { value = StringUtils.EMPTY_STRING; } else if (isIndexedPropertyAssignment(propertyName)) { String checked = checkForNullOrEmptyLiteral(stringValue); value = resolveValue(checked); } else if (isTypedProperty(object, propertyName, Set.class)) { value = toSet(stringValue); } else if (isTypedProperty(object, propertyName, Map.class)) { value = toMap(stringValue); } else if (isTypedProperty(object, propertyName, List.class)) { value = toList(stringValue); } else if (isTypedProperty(object, propertyName, Collection.class)) { value = toCollection(stringValue); } else if (isTypedProperty(object, propertyName, byte[].class)) { value = toBytes(stringValue); } else if (isTypedProperty(object, propertyName, ByteSource.class)) { byte[] bytes = toBytes(stringValue); value = ByteSource.Util.bytes(bytes); } else { String checked = checkForNullOrEmptyLiteral(stringValue); value = resolveValue(checked); } applyProperty(object, propertyName, value); }