public static Collection<PropertyChangeEvent> compare(PropertySource map1, PropertySource map2) {
List<PropertyChangeEvent> changes = new ArrayList<>();
for (Map.Entry<String, PropertyValue> en : map1.getProperties().entrySet()) {
PropertyValue val = map2.get(en.getKey());
if (val == null) {
changes.add(new PropertyChangeEvent(map1, en.getKey(), null, en.getValue().getValue()));
} else if (!val.equals(en.getValue())) {
changes.add(new PropertyChangeEvent(map1, en.getKey(), val.getValue(), en.getValue().getValue()));
}
}
for (Map.Entry<String, PropertyValue> en : map2.getProperties().entrySet()) {
PropertyValue val = map1.get(en.getKey());
if (val == null) {
changes.add(new PropertyChangeEvent(map1, en.getKey(), en.getValue().getValue(), null));
} else if (!val.equals(en.getValue())) {
changes.add(new PropertyChangeEvent(map1, en.getKey(), en.getValue().getValue(), val.getValue()));
}
}
return changes;
}