当前位置: 首页>>代码示例>>Java>>正文


Java MapDifference.entriesOnlyOnLeft方法代码示例

本文整理汇总了Java中com.google.common.collect.MapDifference.entriesOnlyOnLeft方法的典型用法代码示例。如果您正苦于以下问题:Java MapDifference.entriesOnlyOnLeft方法的具体用法?Java MapDifference.entriesOnlyOnLeft怎么用?Java MapDifference.entriesOnlyOnLeft使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.common.collect.MapDifference的用法示例。


在下文中一共展示了MapDifference.entriesOnlyOnLeft方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: entries_only_on_left

import com.google.common.collect.MapDifference; //导入方法依赖的package包/类
@Test
public void entries_only_on_left() {

	MapDifference<Integer, Student> mapDifference = Maps.difference(
			geometryClass, gymClass);

	Map<Integer, Student> studentsOnLeft = mapDifference
			.entriesOnlyOnLeft();

	logger.info(studentsOnLeft);

	assertThat(studentsOnLeft, hasKey(new Integer(456)));
	assertThat(studentsOnLeft, hasKey(new Integer(912)));
}
 
开发者ID:wq19880601,项目名称:java-util-examples,代码行数:15,代码来源:MapDifferenceExample.java

示例2: compareImports

import com.google.common.collect.MapDifference; //导入方法依赖的package包/类
protected void compareImports(Map<String, Vector<Import>> base, Map<String, Vector<Import>> changed,
                              DefaultComparison comparison) {
    DefaultComparison.DefaultSection section = null;
    MapDifference<String, Vector<Import>> mapDiff = Maps.difference(base, changed);

    //If both side imports are equal, return
    if (mapDiff.areEqual()) {
        return;
    }

    Map<String, Vector<Import>> additions = mapDiff.entriesOnlyOnRight();
    if (section == null && additions.size() > 0) {
        section = comparison.newSection();
    }
    processAdditions(comparison, section, additions);

    Map<String, Vector<Import>> removals = mapDiff.entriesOnlyOnLeft();
    if (section == null && removals.size() > 0) {
        section = comparison.newSection();
    }
    processRemovals(comparison, section, removals);

    Map<String, MapDifference.ValueDifference<Vector<Import>>> changes = mapDiff.entriesDiffering();
    if (section == null && changes.size() > 0) {
        section = comparison.newSection();
    }
    processChanges(comparison, section, changes);


    if (section != null) {
        comparison.addSection(ComparatorConstants.WSDL_IMPORTS, section);
    }

}
 
开发者ID:wso2,项目名称:carbon-governance,代码行数:35,代码来源:WSDLImportsComparator.java

示例3: compareBindings

import com.google.common.collect.MapDifference; //导入方法依赖的package包/类
protected void compareBindings(Definition base, Definition changed,
                               DefaultComparison comparison) {

    Map<QName, Binding> baseBinding = base.getAllBindings();
    Map<QName, Binding> changedBinding = changed.getAllBindings();
    DefaultComparison.DefaultSection section = null;
    MapDifference<QName, Binding> mapDiff = Maps.difference(baseBinding, changedBinding);

    //If both side imports are equal, return
    if (mapDiff.areEqual()) {
        return;
    }

    Map<QName, Binding> additions = mapDiff.entriesOnlyOnRight();
    if (section == null && additions.size() > 0) {
        section = comparison.newSection();
    }
    processAdditions(section, additions, changed);

    Map<QName, Binding> removals = mapDiff.entriesOnlyOnLeft();
    if (section == null && removals.size() > 0) {
        section = comparison.newSection();
    }
    processRemovals(section, removals, base);

    Map<QName, MapDifference.ValueDifference<Binding>> changes = mapDiff.entriesDiffering();
    section = processChanges(section, comparison, changes, base, changed);

    if (section != null) {
        comparison.addSection(ComparatorConstants.WSDL_BINDINGS, section);
    }
}
 
开发者ID:wso2,项目名称:carbon-governance,代码行数:33,代码来源:WSDLBindingsComparator.java

示例4: comparePorts

import com.google.common.collect.MapDifference; //导入方法依赖的package包/类
protected void comparePorts(Definition base, Definition changed, DefaultComparison comparison) {
    DefaultComparison.DefaultSection section = null;
    Set<QName> commonKeys = Sets.intersection(base.getAllServices().keySet(), changed.getAllServices().keySet());
    if (commonKeys.size() > 0) {
        for (QName service : commonKeys) {
            Map<QName, Port> basePorts = base.getService(service).getPorts();
            Map<QName, Port> changedPorts = changed.getService(service).getPorts();
            MapDifference<QName, Port> mapDiff = Maps.difference(basePorts, changedPorts);

            if (!mapDiff.areEqual()) {
                Map<QName, Port> additions = mapDiff.entriesOnlyOnRight();
                if (section == null && additions.size() > 0) {
                    section = comparison.newSection();
                }
                processAdditions(section, additions, changed);

                Map<QName, Port> removals = mapDiff.entriesOnlyOnLeft();
                if (section == null && removals.size() > 0) {
                    section = comparison.newSection();
                }
                processRemovals(section, removals, base);

                Map<QName, MapDifference.ValueDifference<Port>> changes = mapDiff.entriesDiffering();
                section = processChanges(section, comparison, changes, base, changed);
            }
        }
    }

    if (section != null) {
        comparison.addSection(ComparatorConstants.WSDL_PORTS, section);
    }
}
 
开发者ID:wso2,项目名称:carbon-governance,代码行数:33,代码来源:WSDLPortComparator.java

示例5: compareServices

import com.google.common.collect.MapDifference; //导入方法依赖的package包/类
protected void compareServices(Definition base, Definition changed, DefaultComparison comparison) {
    DefaultComparison.DefaultSection section = null;
    Map<QName, Service> baseService = base.getAllServices();
    Map<QName, Service> changedService = changed.getAllServices();
    MapDifference<QName, Service> mapDiff = Maps.difference(baseService, changedService);

    //If both side services are equal, return
    if (mapDiff.areEqual()) {
        return;
    }

    Map<QName, Service> additions = mapDiff.entriesOnlyOnRight();
    if (section == null && additions.size() > 0) {
        section = comparison.newSection();
    }
    processAdditions(section, additions, changed);

    Map<QName, Service> removals = mapDiff.entriesOnlyOnLeft();
    if (section == null && removals.size() > 0) {
        section = comparison.newSection();
    }
    processRemovals(section, removals, base);

    Map<QName, MapDifference.ValueDifference<Service>> changes = mapDiff.entriesDiffering();
    section = processChanges(section, comparison, changes, base, changed);

    if (section != null) {
        comparison.addSection(ComparatorConstants.WSDL_SERVICE, section);
    }
}
 
开发者ID:wso2,项目名称:carbon-governance,代码行数:31,代码来源:WSDLServicesComparator.java

示例6: RepositoryVisitor

import com.google.common.collect.MapDifference; //导入方法依赖的package包/类
public RepositoryVisitor(final Path projectPath,
                         final String _projectRoot,
                         final boolean cleanTempDir) {
    this.root = makeTempRootDirectory(_projectRoot,
                                      cleanTempDir);

    try {
        if (_projectRoot != null && !_projectRoot.equals("")) {
            loadIndex(root.getAbsolutePath());
        }
        visitPaths(root,
                   Files.newDirectoryStream(projectPath));
        if (oldIdentityHash != null) {
            MapDifference<String, String> difference = Maps.difference(oldIdentityHash,
                                                                       identityHash);
            Map<String, String> deletedFiles = difference.entriesOnlyOnLeft();
            for (String path : deletedFiles.keySet()) {
                boolean deleted = new File(root.getAbsolutePath().replace(projectPath.toString(),
                                                                          "") + "/" + path).delete();
                System.out.println("Deleted: " + root.getAbsolutePath().replace(projectPath.toString(),
                                                                                "") + "/" + path + " -> " + deleted);
            }
        }
        storeIndex(root.getAbsolutePath());
    } catch (IOException | NoSuchAlgorithmException ex) {
        throw new RuntimeException(ex);
    }
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:29,代码来源:RepositoryVisitor.java

示例7: computeDeleteMap

import com.google.common.collect.MapDifference; //导入方法依赖的package包/类
public Map<String, Entity> computeDeleteMap(final Class<? extends Entity> clazz)
{
    final MapDifference<String, Entity> diff = getDiff(clazz);
    final Map<String, Entity> result         = diff.entriesOnlyOnLeft();

    return result;
}
 
开发者ID:interruptus,项目名称:interruptus,代码行数:8,代码来源:ConfigDiffTool.java

示例8: verify

import com.google.common.collect.MapDifference; //导入方法依赖的package包/类
/**
 * Performs verification of the given files.
 * @param checker {@link Checker} instance
 * @param processedFiles files to process.
 * @param expectedViolations a map of expected violations per files.
 * @throws Exception if exception occurs during verification process.
 */
protected final void verify(Checker checker,
                      File[] processedFiles,
                      Map<String, List<String>> expectedViolations)
        throws Exception {
    stream.flush();
    final List<File> theFiles = new ArrayList<File>();
    Collections.addAll(theFiles, processedFiles);
    final int errs = checker.process(theFiles);

    // process each of the lines
    final Map<String, List<String>> actualViolations = getActualViolations(errs);
    final Map<String, List<String>> realExpectedViolations =
            Maps.filterValues(expectedViolations, new Predicate<List<String>>() {
                @Override
                public boolean apply(List<String> input) {
                    return !input.isEmpty();
                }
            });
    final MapDifference<String, List<String>> violationDifferences =
            Maps.difference(realExpectedViolations, actualViolations);

    final Map<String, List<String>> missingViolations =
            violationDifferences.entriesOnlyOnLeft();
    final Map<String, List<String>> unexpectedViolations =
            violationDifferences.entriesOnlyOnRight();
    final Map<String, MapDifference.ValueDifference<List<String>>> differingViolations =
            violationDifferences.entriesDiffering();

    final StringBuilder message = new StringBuilder(256);
    if (!missingViolations.isEmpty()) {
        message.append("missing violations: ").append(missingViolations);
    }
    if (!unexpectedViolations.isEmpty()) {
        if (message.length() > 0) {
            message.append('\n');
        }
        message.append("unexpected violations: ").append(unexpectedViolations);
    }
    if (!differingViolations.isEmpty()) {
        if (message.length() > 0) {
            message.append('\n');
        }
        message.append("differing violations: ").append(differingViolations);
    }

    assertTrue(message.toString(),
            missingViolations.isEmpty()
                    && unexpectedViolations.isEmpty()
                    && differingViolations.isEmpty());

    checker.destroy();
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:60,代码来源:AbstractModuleTestSupport.java

示例9: sieveAlreadyLinkedTagRequests

import com.google.common.collect.MapDifference; //导入方法依赖的package包/类
private Multimap<String, String> sieveAlreadyLinkedTagRequests(
        MapDifference<String, Collection<String>> linesDiff) {

    log.debug("linesDiff.equal?: {}", linesDiff.areEqual());
    log.trace("linesDiff.differences: {}", linesDiff.entriesDiffering());
    log.trace("linesDiff.left: {}", linesDiff.entriesOnlyOnLeft());
    log.trace("linesDiff.right: {}", linesDiff.entriesOnlyOnRight());
    log.trace("linesDiff.common: {}", linesDiff.entriesInCommon());

    Multimap<String, String> knownTagsForLinking = null;

    if (linesDiff.areEqual()) {
        // all requested tags have already been linked to the requested pojos
        // nothing to do
        log.info("All known tags already linked to requested pojos - no-op");
        knownTagsForLinking = HashMultimap.create();
    } else {
        log.info("Lines differ: {} differences, {} onLeft, {} onRight, {} common",
                  linesDiff.entriesDiffering().size(),
                  linesDiff.entriesOnlyOnLeft().size(),
                  linesDiff.entriesOnlyOnRight().size(),
                  linesDiff.entriesInCommon().size());

        // always keep the tags not linked yet from the requested lines - ie. the "on left" ones
        // (the "only in CSV" lines)
        Map<String, Collection<String>> retainedTags = linesDiff.entriesOnlyOnLeft();

        knownTagsForLinking = MultimapsUtil.forMap(retainedTags);
        log.debug("retaining leftSide: {}", retainedTags);

        // for entries which are present both in CSV and in the already linked associations:
        // further the filtering so as to exclude the entries already linked
        Map<String, ValueDifference<Collection<String>>> mapsDiff = linesDiff.entriesDiffering();
        log.debug("filtering mapsDiff: {}", mapsDiff);

        for (String tag : mapsDiff.keySet()) {
            ValueDifference<Collection<String>> differencesForTag = mapsDiff.get(tag);

            Collection<String> pojosOnlyInCsvForTag = differencesForTag.leftValue();
            Collection<String> pojosAlreadyLinkedForTag = differencesForTag.rightValue();

            Set<String> onlyInCsv = Sets.newHashSet(pojosOnlyInCsvForTag);
            Set<String> alreadyLinked = Sets.newHashSet(pojosAlreadyLinkedForTag);

            // keep the tags present in csv but not already linked in database
            Set<String> retainedPojosNames = Sets.difference(onlyInCsv, alreadyLinked);

            knownTagsForLinking.putAll(tag, retainedPojosNames);
        }

        log.info("Retained {} known tags not linked to requested pojos",
                 knownTagsForLinking.size());
    }

    log.debug("knownTagsForLinking: {} - {}", knownTagsForLinking.size(), knownTagsForLinking);

    return knownTagsForLinking;
}
 
开发者ID:imagopole,项目名称:omero-csv-tools,代码行数:59,代码来源:DefaultCsvAnnotationService.java

示例10: verify

import com.google.common.collect.MapDifference; //导入方法依赖的package包/类
/**
 * Performs verification of the given files.
 * @param checker {@link Checker} instance
 * @param processedFiles files to process.
 * @param expectedViolations a map of expected violations per files.
 * @throws Exception if exception occurs during verification process.
 */
protected final void verify(Checker checker,
                      File[] processedFiles,
                      Map<String, List<String>> expectedViolations)
        throws Exception {
    stream.flush();
    final List<File> theFiles = new ArrayList<>();
    Collections.addAll(theFiles, processedFiles);
    final int errs = checker.process(theFiles);

    // process each of the lines
    final Map<String, List<String>> actualViolations = getActualViolations(errs);
    final Map<String, List<String>> realExpectedViolations =
            Maps.filterValues(expectedViolations, input -> !input.isEmpty());
    final MapDifference<String, List<String>> violationDifferences =
            Maps.difference(realExpectedViolations, actualViolations);

    final Map<String, List<String>> missingViolations =
            violationDifferences.entriesOnlyOnLeft();
    final Map<String, List<String>> unexpectedViolations =
            violationDifferences.entriesOnlyOnRight();
    final Map<String, MapDifference.ValueDifference<List<String>>> differingViolations =
            violationDifferences.entriesDiffering();

    final StringBuilder message = new StringBuilder(256);
    if (!missingViolations.isEmpty()) {
        message.append("missing violations: ").append(missingViolations);
    }
    if (!unexpectedViolations.isEmpty()) {
        if (message.length() > 0) {
            message.append('\n');
        }
        message.append("unexpected violations: ").append(unexpectedViolations);
    }
    if (!differingViolations.isEmpty()) {
        if (message.length() > 0) {
            message.append('\n');
        }
        message.append("differing violations: ").append(differingViolations);
    }

    assertTrue(message.toString(),
            missingViolations.isEmpty()
                    && unexpectedViolations.isEmpty()
                    && differingViolations.isEmpty());

    checker.destroy();
}
 
开发者ID:checkstyle,项目名称:checkstyle,代码行数:55,代码来源:AbstractModuleTestSupport.java


注:本文中的com.google.common.collect.MapDifference.entriesOnlyOnLeft方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。