in core-it-support/core-it-plugins/maven-it-plugin-configuration/src/main/java/org/apache/maven/plugin/coreit/PropertiesUtil.java [91:144]
public static void serialize(Properties props, String key, Object value) {
if (value != null && value.getClass().isArray()) {
props.setProperty(key, Integer.toString(Array.getLength(value)));
for (int i = Array.getLength(value) - 1; i >= 0; i--) {
serialize(props, key + "." + i, Array.get(value, i));
}
} else if (value instanceof Collection) {
Collection collection = (Collection) value;
props.setProperty(key, Integer.toString(collection.size()));
int i = 0;
for (Iterator it = collection.iterator(); it.hasNext(); i++) {
serialize(props, key + "." + i, it.next());
}
} else if (value instanceof Map) {
Map map = (Map) value;
props.setProperty(key, Integer.toString(map.size()));
int i = 0;
for (Iterator it = map.keySet().iterator(); it.hasNext(); i++) {
Object k = it.next();
Object v = map.get(k);
serialize(props, key + "." + k, v);
}
} else if (value instanceof PlexusConfiguration) {
PlexusConfiguration config = (PlexusConfiguration) value;
String val = config.getValue(null);
if (val != null) {
props.setProperty(key + ".value", val);
}
String[] attributes = config.getAttributeNames();
props.setProperty(key + ".attributes", Integer.toString(attributes.length));
for (int i = attributes.length - 1; i >= 0; i--) {
props.setProperty(key + ".attributes." + attributes[i], config.getAttribute(attributes[i], ""));
}
PlexusConfiguration children[] = config.getChildren();
props.setProperty(key + ".children", Integer.toString(children.length));
Map<String, Integer> indices = new HashMap<>();
for (PlexusConfiguration child : children) {
String name = child.getName();
Integer index = indices.get(name);
if (index == null) {
index = 0;
}
serialize(props, key + ".children." + name + "." + index, child);
indices.put(name, index + 1);
}
} else if (value instanceof Date) {
props.setProperty(key, new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format((Date) value));
} else if (value != null) {
props.setProperty(key, value.toString());
}
}