Java Code Examples for org.gradle.util.CollectionUtils#SetDiff

The following examples show how to use org.gradle.util.CollectionUtils#SetDiff . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GeneratedArchiveBuildOutcomeComparator.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public GeneratedArchiveBuildOutcomeComparisonResult compare(BuildOutcomeAssociation<GeneratedArchiveBuildOutcome> association) {
    GeneratedArchiveBuildOutcome source = association.getSource();
    GeneratedArchiveBuildOutcome target = association.getTarget();

    Set<ArchiveEntry> sourceEntries;
    if (source.getArchiveFile() != null && source.getArchiveFile().exists()) {
        sourceEntries = archiveToEntriesTransformer.transform(source.getArchiveFile());
    } else {
        sourceEntries = Collections.emptySet();
    }

    Set<ArchiveEntry> targetEntries;
    if (target.getArchiveFile() != null && target.getArchiveFile().exists()) {
        targetEntries = archiveToEntriesTransformer.transform(target.getArchiveFile());
    } else {
        targetEntries = Collections.emptySet();
    }

    CollectionUtils.SetDiff<ArchiveEntry> diff = CollectionUtils.diffSetsBy(sourceEntries, targetEntries, new Transformer<String, ArchiveEntry>() {
        public String transform(ArchiveEntry entry) {
            return entry.getPath();
        }
    });

    SortedSet<ArchiveEntryComparison> entryComparisons = new TreeSet<ArchiveEntryComparison>(new Comparator<ArchiveEntryComparison>() {
        public int compare(ArchiveEntryComparison o1, ArchiveEntryComparison o2) {
            return o1.getPath().compareTo(o2.getPath());
        }
    });

    for (ArchiveEntry sourceOnly : diff.leftOnly) {
        entryComparisons.add(new ArchiveEntryComparison(sourceOnly.getPath(), sourceOnly, null));
    }

    for (CollectionUtils.SetDiff.Pair<ArchiveEntry> pair : diff.common) {
        entryComparisons.add(new ArchiveEntryComparison(pair.left.getPath(), pair.left, pair.right));
    }

    for (ArchiveEntry targetOnly : diff.rightOnly) {
        entryComparisons.add(new ArchiveEntryComparison(targetOnly.getPath(), null, targetOnly));
    }

    return new GeneratedArchiveBuildOutcomeComparisonResult(association, entryComparisons);
}
 
Example 2
Source File: GeneratedArchiveBuildOutcomeComparator.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public GeneratedArchiveBuildOutcomeComparisonResult compare(BuildOutcomeAssociation<GeneratedArchiveBuildOutcome> association) {
    GeneratedArchiveBuildOutcome source = association.getSource();
    GeneratedArchiveBuildOutcome target = association.getTarget();

    Set<ArchiveEntry> sourceEntries;
    if (source.getArchiveFile() != null && source.getArchiveFile().exists()) {
        sourceEntries = archiveToEntriesTransformer.transform(source.getArchiveFile());
    } else {
        sourceEntries = Collections.emptySet();
    }

    Set<ArchiveEntry> targetEntries;
    if (target.getArchiveFile() != null && target.getArchiveFile().exists()) {
        targetEntries = archiveToEntriesTransformer.transform(target.getArchiveFile());
    } else {
        targetEntries = Collections.emptySet();
    }

    CollectionUtils.SetDiff<ArchiveEntry> diff = CollectionUtils.diffSetsBy(sourceEntries, targetEntries, new Transformer<String, ArchiveEntry>() {
        public String transform(ArchiveEntry entry) {
            return entry.getPath();
        }
    });

    SortedSet<ArchiveEntryComparison> entryComparisons = new TreeSet<ArchiveEntryComparison>(new Comparator<ArchiveEntryComparison>() {
        public int compare(ArchiveEntryComparison o1, ArchiveEntryComparison o2) {
            return o1.getPath().compareTo(o2.getPath());
        }
    });

    for (ArchiveEntry sourceOnly : diff.leftOnly) {
        entryComparisons.add(new ArchiveEntryComparison(sourceOnly.getPath(), sourceOnly, null));
    }

    for (CollectionUtils.SetDiff.Pair<ArchiveEntry> pair : diff.common) {
        entryComparisons.add(new ArchiveEntryComparison(pair.left.getPath(), pair.left, pair.right));
    }

    for (ArchiveEntry targetOnly : diff.rightOnly) {
        entryComparisons.add(new ArchiveEntryComparison(targetOnly.getPath(), null, targetOnly));
    }

    return new GeneratedArchiveBuildOutcomeComparisonResult(association, entryComparisons);
}
 
Example 3
Source File: GeneratedArchiveBuildOutcomeComparator.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public GeneratedArchiveBuildOutcomeComparisonResult compare(BuildOutcomeAssociation<GeneratedArchiveBuildOutcome> association) {
    GeneratedArchiveBuildOutcome source = association.getSource();
    GeneratedArchiveBuildOutcome target = association.getTarget();

    Set<ArchiveEntry> sourceEntries;
    if (source.getArchiveFile() != null && source.getArchiveFile().exists()) {
        sourceEntries = archiveToEntriesTransformer.transform(source.getArchiveFile());
    } else {
        sourceEntries = Collections.emptySet();
    }

    Set<ArchiveEntry> targetEntries;
    if (target.getArchiveFile() != null && target.getArchiveFile().exists()) {
        targetEntries = archiveToEntriesTransformer.transform(target.getArchiveFile());
    } else {
        targetEntries = Collections.emptySet();
    }

    CollectionUtils.SetDiff<ArchiveEntry> diff = CollectionUtils.diffSetsBy(sourceEntries, targetEntries, new Transformer<String, ArchiveEntry>() {
        public String transform(ArchiveEntry entry) {
            return entry.getPath();
        }
    });

    SortedSet<ArchiveEntryComparison> entryComparisons = new TreeSet<ArchiveEntryComparison>(new Comparator<ArchiveEntryComparison>() {
        public int compare(ArchiveEntryComparison o1, ArchiveEntryComparison o2) {
            return o1.getPath().compareTo(o2.getPath());
        }
    });

    for (ArchiveEntry sourceOnly : diff.leftOnly) {
        entryComparisons.add(new ArchiveEntryComparison(sourceOnly.getPath(), sourceOnly, null));
    }

    for (CollectionUtils.SetDiff.Pair<ArchiveEntry> pair : diff.common) {
        entryComparisons.add(new ArchiveEntryComparison(pair.left.getPath(), pair.left, pair.right));
    }

    for (ArchiveEntry targetOnly : diff.rightOnly) {
        entryComparisons.add(new ArchiveEntryComparison(targetOnly.getPath(), null, targetOnly));
    }

    return new GeneratedArchiveBuildOutcomeComparisonResult(association, entryComparisons);
}
 
Example 4
Source File: GeneratedArchiveBuildOutcomeComparator.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public GeneratedArchiveBuildOutcomeComparisonResult compare(BuildOutcomeAssociation<GeneratedArchiveBuildOutcome> association) {
    GeneratedArchiveBuildOutcome source = association.getSource();
    GeneratedArchiveBuildOutcome target = association.getTarget();

    Set<ArchiveEntry> sourceEntries;
    if (source.getArchiveFile() != null && source.getArchiveFile().exists()) {
        sourceEntries = archiveToEntriesTransformer.transform(source.getArchiveFile());
    } else {
        sourceEntries = Collections.emptySet();
    }

    Set<ArchiveEntry> targetEntries;
    if (target.getArchiveFile() != null && target.getArchiveFile().exists()) {
        targetEntries = archiveToEntriesTransformer.transform(target.getArchiveFile());
    } else {
        targetEntries = Collections.emptySet();
    }

    CollectionUtils.SetDiff<ArchiveEntry> diff = CollectionUtils.diffSetsBy(sourceEntries, targetEntries, new Transformer<String, ArchiveEntry>() {
        public String transform(ArchiveEntry entry) {
            return entry.getPath();
        }
    });

    SortedSet<ArchiveEntryComparison> entryComparisons = new TreeSet<ArchiveEntryComparison>(new Comparator<ArchiveEntryComparison>() {
        public int compare(ArchiveEntryComparison o1, ArchiveEntryComparison o2) {
            return o1.getPath().compareTo(o2.getPath());
        }
    });

    for (ArchiveEntry sourceOnly : diff.leftOnly) {
        entryComparisons.add(new ArchiveEntryComparison(sourceOnly.getPath(), sourceOnly, null));
    }

    for (CollectionUtils.SetDiff.Pair<ArchiveEntry> pair : diff.common) {
        entryComparisons.add(new ArchiveEntryComparison(pair.left.getPath(), pair.left, pair.right));
    }

    for (ArchiveEntry targetOnly : diff.rightOnly) {
        entryComparisons.add(new ArchiveEntryComparison(targetOnly.getPath(), null, targetOnly));
    }

    return new GeneratedArchiveBuildOutcomeComparisonResult(association, entryComparisons);
}