protected void computeDiff()

in src/main/java/org/apache/sling/feature/diff/impl/ConfigurationsComparator.java [67:108]


    protected void computeDiff(Configuration previous, Configuration current, Feature target) {
        Dictionary<String, Object> previousProperties = previous.getProperties();
        Dictionary<String, Object> currentProperties = current.getProperties();

        Configuration targetConfiguration = new Configuration(previous.getPid());
        Dictionary<String, Object> targetProperties = targetConfiguration.getProperties();

        Enumeration<String> previousKeys = previousProperties.keys();
        while (previousKeys.hasMoreElements()) {
            String previousKey = previousKeys.nextElement();

            // skip 'service.pid' and 'service.factoryPid' keys
            // no other way to check if a key was removed in a dictionary
            if (!isReservedKey(previousKey) && hasKey(previousKey, currentProperties.keys())) {
                Object previousValue = previousProperties.get(previousKey);
                Object currentValue = currentProperties.get(previousKey);

                if (!areEquals(previousValue, currentValue)) {
                    targetProperties.put(previousKey, currentValue);
                }
            }
        }

        Enumeration<String> currentKeys = currentProperties.keys();
        while (currentKeys.hasMoreElements()) {
            String currentKey = currentKeys.nextElement();

            // skip 'service.pid' and 'service.factoryPid' keys
            if (!isReservedKey(currentKey)) {
                Object previousValue = previousProperties.get(currentKey);
                Object currentValue = currentProperties.get(currentKey);

                if (previousValue == null && currentValue != null) {
                    targetProperties.put(currentKey, currentValue);
                }
            }
        }

        if (!targetProperties.isEmpty()) {
            target.getConfigurations().add(targetConfiguration);
        }
    }