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


Java MapDifference.entriesDiffering方法代码示例

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


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

示例1: handleTepIpsUpdateEvent

import com.google.common.collect.MapDifference; //导入方法依赖的package包/类
private void handleTepIpsUpdateEvent(OpenvswitchOtherConfigs origLocalIps,
        OpenvswitchOtherConfigs updatedLocalIps, String nodeId) {
    Map<String,
            String> origLocalIpMap = Optional
                    .ofNullable(bridgeMgr.getMultiValueMap(origLocalIps.getOtherConfigValue()))
                    .orElse(Collections.emptyMap());
    Map<String,
            String> updatedLocalIpMap = Optional
                    .ofNullable(bridgeMgr.getMultiValueMap(updatedLocalIps.getOtherConfigValue()))
                    .orElse(Collections.emptyMap());
    MapDifference<String, String> mapDiff = Maps.difference(origLocalIpMap, updatedLocalIpMap);

    // Handling only underlay network updates for existing for TEP ips
    // Added and removed TEP ips will be handled by
    // TunnelStateChangeListener
    Map<String, ValueDifference<String>> entriesDiffering = mapDiff.entriesDiffering();
    if (entriesDiffering == null || entriesDiffering.isEmpty()) {
        LOG.trace("No underlay network changes detected for for node {}", nodeId);
        return;
    }

    Optional<BigInteger> dpIdOpt = bridgeMgr.getDpIdFromManagerNodeId(nodeId);
    if (!dpIdOpt.isPresent()) {
        LOG.debug("Failed to get DPN id for node {}", nodeId);
        return;
    }

    BigInteger dpId = dpIdOpt.get();
    for (Entry<String, ValueDifference<String>> entry : entriesDiffering.entrySet()) {
        String srcTepIp = entry.getKey();
        ValueDifference<String> valueDiff = entry.getValue();
        String origUnderlayNetwork = valueDiff.leftValue();
        String updatedUnderlayNetwork = valueDiff.rightValue();
        handleTepIpChangeEvent(dpId, srcTepIp, origUnderlayNetwork, updatedUnderlayNetwork);
    }
}
 
开发者ID:opendaylight,项目名称:netvirt,代码行数:37,代码来源:TunnelUnderlayNetworkChangeListener.java

示例2: getPreferenceChanges

import com.google.common.collect.MapDifference; //导入方法依赖的package包/类
public Map<String, ValueDifference<String>> getPreferenceChanges() {
	Map<String, String> currentSettings = Maps.newHashMapWithExpectedSize(keys.length);
	for (String key : keys) {
		currentSettings.put(key, preferenceStore.getString(key));
	}
	MapDifference<String, String> mapDifference = Maps.difference(currentSettings, originalSettings);
	Map<String, ValueDifference<String>> entriesDiffering = mapDifference.entriesDiffering();
	return entriesDiffering;
}
 
开发者ID:cplutte,项目名称:bts,代码行数:10,代码来源:OptionsConfigurationBlock.java

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: computeUpdateMap

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

    for (final Map.Entry<String, ValueDifference<Entity>> entry : differing.entrySet()) {
        final String key                    = entry.getKey();
        final ValueDifference<Entity> value = entry.getValue();

        result.put(key, value.rightValue());
    }

    return result;
}
 
开发者ID:interruptus,项目名称:interruptus,代码行数:16,代码来源: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: compareTo

import com.google.common.collect.MapDifference; //导入方法依赖的package包/类
@Override
public SchemaChangeModel compareTo(FieldSchema fieldSchema) {
	// Create the initial empty change
	SchemaChangeModel change = new SchemaChangeModel(EMPTY, getName());

	Map<String, Object> schemaPropertiesA = getAllChangeProperties();
	Map<String, Object> schemaPropertiesB = fieldSchema.getAllChangeProperties();

	// Check whether the field type has been changed
	if (!fieldSchema.getType().equals(getType())) {
		change.setOperation(CHANGEFIELDTYPE);
		change.setProperty(TYPE_KEY, fieldSchema.getType());
		if (fieldSchema instanceof ListFieldSchema) {
			change.getProperties().put(LIST_TYPE_KEY, ((ListFieldSchema) fieldSchema).getListType());
		}
		// Add fieldB properties which are new
		change.getProperties().putAll(schemaPropertiesB);
	} else {

		// Generate a structural diff. This way it is easy to determine which field properties have been updated, added or removed.
		MapDifference<String, Object> diff = Maps.difference(schemaPropertiesA, schemaPropertiesB, new Equivalence<Object>() {

			@Override
			protected boolean doEquivalent(Object a, Object b) {
				return Objects.deepEquals(a, b);
			}

			@Override
			protected int doHash(Object t) {
				return t.hashCode();
			}

		});

		// Check whether fields have been updated
		Map<String, ValueDifference<Object>> differentProperties = diff.entriesDiffering();
		if (!differentProperties.isEmpty()) {
			change.setOperation(UPDATEFIELD);
			for (String key : differentProperties.keySet()) {
				change.getProperties().put(key, differentProperties.get(key).rightValue());
			}
		}
	}
	return change;
}
 
开发者ID:gentics,项目名称:mesh,代码行数:46,代码来源:AbstractFieldSchema.java

示例10: 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

示例11: 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

示例12: getPreferenceChanges

import com.google.common.collect.MapDifference; //导入方法依赖的package包/类
/**
 * @param originalSettings
 *            the settings before applying the values of the form page
 * @param currentSettings
 *            the settings after collecting the values of the form page
 * @return a map keyed by the preference store key (e.g. outlet.es5.autobuilding for compiler (resp. output
 *         configuration) with name 'es5' and property 'autobuilding') containing old and new value. Only keys whose
 *         values has been changed are included.
 */
private Map<String, ValueDifference<String>> getPreferenceChanges(Map<String, String> originalSettings,
		Map<String, String> currentSettings) {
	MapDifference<String, String> mapDifference = Maps.difference(currentSettings, originalSettings);
	Map<String, ValueDifference<String>> entriesDiffering = mapDifference.entriesDiffering();
	return entriesDiffering;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:16,代码来源:AbstractN4JSPreferenceStoreAccessor.java

示例13: entries_differing

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

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

	System.out.println(mapDifference.entriesDiffering()); // with same keys

	Map<Integer, ValueDifference<Student>> sameKeyDifferentValue = mapDifference
			.entriesDiffering();

	assertThat(sameKeyDifferentValue.keySet(), hasItems(new Integer(789)));
}
 
开发者ID:wq19880601,项目名称:java-util-examples,代码行数:14,代码来源:MapDifferenceExample.java

示例14: getPreferenceChanges

import com.google.common.collect.MapDifference; //导入方法依赖的package包/类
/**
 * @param originalSettings
 *            the settings before applying the values of the form page
 * @param currentSettings
 *            the settings after collecting the values of the form page
 * @return a map keyed by the preference store key (e.g. outlet.es5.autobuilding for compiler (resp. output
 *         configuration) with name 'es5' and property 'autobuilding') containing old and new value. Only keys whose
 *         values has been changed are included.
 */
private Map<String, ValueDifference<String>> getPreferenceChanges(Map<String, String> originalSettings,
		Map<String, String> currentSettings) {
	MapDifference<String, String> mapDifference = Maps.difference(currentSettings, originalSettings);
	return mapDifference.entriesDiffering();
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:15,代码来源:AbstractN4JSPreferencePage.java


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