All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.developerdan.blocklist.tools.ListDiff Maven / Gradle / Ivy

There is a newer version: 1.2.1
Show newest version
package com.developerdan.blocklist.tools;

import java.util.NavigableSet;
import java.util.TreeSet;

public class ListDiff {

    private ListDiff() { }

    public static String domainList(final NavigableSet before, final NavigableSet after) {
        var patchBuilder = new PatchBuilder();

        TreeSet allDomains = new TreeSet<>(before);
        allDomains.addAll(after);
        for(Domain entry : allDomains) {
            if (!before.contains(entry)) {
                patchBuilder.added(entry);
            } else if (!after.contains(entry)) {
                patchBuilder.removed(entry);
            } else {
                patchBuilder.noChange(entry);
            }
        }
        return patchBuilder.toString();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy