/** * Initializes the configuration. Called during construction. */ protected void init() { for (Map.Entry<String, Map<String, Object>> configEntry : config.entrySet()) { @SuppressWarnings("unchecked") Map<String, Object> value = (Map<String, Object>) evaluateAll(configEntry.getValue()); configEntry.setValue(value); } }
/** * Initializes the configuration. Called during construction. */ protected void init() { for (Map.Entry<String, Map<String, Object>> configEntry : config.entrySet()) { @SuppressWarnings("unchecked") Map<String, Object> value = (Map<String, Object>) evaluateAll(configEntry.getValue()); configEntry.setValue(value); } }
private Object evaluateAll(Object value) { if (value instanceof CharSequence) { return value.toString(); } else if (value instanceof Map<?, ?>) { Map<?, ?> mapValue = (Map<?, ?>) value; ImmutableMap.Builder<Object, Object> newMap = ImmutableMap.builder(); for (Map.Entry<?, ?> entry : mapValue.entrySet()) { newMap.put(entry.getKey(), evaluateAll(entry.getValue())); } return newMap.build(); } else if (value instanceof List<?>) { ImmutableList.Builder<Object> newList = ImmutableList.builder(); for (Object entry : (List<?>) value) { newList.add(evaluateAll(entry)); } return newList.build(); } else { return value; } } }
private Object evaluateAll(Object value) { if (value instanceof CharSequence) { return value.toString(); } else if (value instanceof Map<?, ?>) { Map<?, ?> mapValue = (Map<?, ?>) value; ImmutableMap.Builder<Object, Object> newMap = ImmutableMap.builder(); for (Map.Entry<?, ?> entry : mapValue.entrySet()) { newMap.put(entry.getKey(), evaluateAll(entry.getValue())); } return newMap.build(); } else if (value instanceof List<?>) { ImmutableList.Builder<Object> newList = ImmutableList.builder(); for (Object entry : (List<?>) value) { newList.add(evaluateAll(entry)); } return newList.build(); } else { return value; } } }