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


Java ValueDifference类代码示例

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


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

示例1: doDifference

import com.google.common.collect.MapDifference.ValueDifference; //导入依赖的package包/类
private static <K, V> void doDifference(
    Map<? extends K, ? extends V> left,
    Map<? extends K, ? extends V> right,
    Equivalence<? super V> valueEquivalence,
    Map<K, V> onlyOnLeft,
    Map<K, V> onlyOnRight,
    Map<K, V> onBoth,
    Map<K, MapDifference.ValueDifference<V>> differences) {
  for (Entry<? extends K, ? extends V> entry : left.entrySet()) {
    K leftKey = entry.getKey();
    V leftValue = entry.getValue();
    if (right.containsKey(leftKey)) {
      V rightValue = onlyOnRight.remove(leftKey);
      if (valueEquivalence.equivalent(leftValue, rightValue)) {
        onBoth.put(leftKey, leftValue);
      } else {
        differences.put(leftKey, ValueDifferenceImpl.create(leftValue, rightValue));
      }
    } else {
      onlyOnLeft.put(leftKey, leftValue);
    }
  }
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:24,代码来源:Maps.java

示例2: isPageBreak

import com.google.common.collect.MapDifference.ValueDifference; //导入依赖的package包/类
private BiFunction<Entry<ImmutableMap<String, Object>, Collection<Blob>>, Entry<ImmutableMap<String, Object>, Collection<Blob>>, Boolean> isPageBreak(Path path) {
	if (!path.isPaging()) {
		return (a,b) -> false;
	}
		
	return (a,b) -> {
		ImmutableMap<String, Object> keysA = a.getKey();
		ImmutableMap<String, Object> keysB = b.getKey();
		
		
		Map<String, ValueDifference<Object>> diff = Maps.difference(keysA, keysB).entriesDiffering();
		Set<String> keySet = diff.keySet();
		
		boolean onlyDifferentPage = keySet.size()==1 && keySet.contains(Path.PAGE);
		
		return !onlyDifferentPage;
	};
}
 
开发者ID:flapdoodle-oss,项目名称:de.flapdoodle.solid,代码行数:19,代码来源:DefaultSiteGenerator.java

示例3: handleChangedLocalIps

import com.google.common.collect.MapDifference.ValueDifference; //导入依赖的package包/类
private void handleChangedLocalIps(Map<String, ValueDifference<String>> changedEntries, BigInteger dpId,
        Set<String> zonePrefixes, Map<String, List<String>> tepTzMap, WriteTransaction tx) {
    if (changedEntries == null || changedEntries.isEmpty()) {
        LOG.trace("No changed local_ips found for DPN {}", dpId);
        return;
    }

    LOG.debug("Changing underlay network mapping for local_ips {} on DPN {}", changedEntries.keySet(), dpId);
    changedEntries.forEach((ipAddress, underlayNetworkDiff) -> {
        List<String> zoneNames = tepTzMap.get(ipAddress);
        if (zoneNames != null) {
            for (String zoneName : zoneNames) {
                String removedUnderlayNetwork = underlayNetworkDiff.leftValue();
                String addedUnderlayNetwork = underlayNetworkDiff.rightValue();
                Optional<String> zonePrefixOpt = getZonePrefixForUnderlayNetwork(zoneName, removedUnderlayNetwork);
                if (zonePrefixOpt.isPresent()) {
                    String zonePrefix = zonePrefixOpt.get();
                    removeVtep(zoneName, dpId, ipAddress, tx);
                    zonePrefixes.add(zonePrefix);
                    String newZoneName = getTzNameForUnderlayNetwork(zonePrefix, addedUnderlayNetwork);
                    updateTransportZone(newZoneName, dpId, ipAddress, tx);
                }
            }
        }
    });
}
 
开发者ID:opendaylight,项目名称:netvirt,代码行数:27,代码来源:TransportZoneNotificationUtil.java

示例4: doDifference

import com.google.common.collect.MapDifference.ValueDifference; //导入依赖的package包/类
private static <K, V> void doDifference(Map<? extends K, ? extends V> left, Map<? extends K, ? extends V> right, Equivalence<? super V> valueEquivalence, Map<K, V> onlyOnLeft, Map<K, V> onlyOnRight, Map<K, V> onBoth, Map<K, MapDifference.ValueDifference<V>> differences) {
  for (Entry<? extends K, ? extends V> entry : left.entrySet()) {
    K leftKey = entry.getKey();
    V leftValue = entry.getValue();
    if (right.containsKey(leftKey)) {
      V rightValue = onlyOnRight.remove(leftKey);
      if (valueEquivalence.equivalent(leftValue, rightValue)) {
        onBoth.put(leftKey, leftValue);
      } else {
        differences.put(leftKey, ValueDifferenceImpl.create(leftValue, rightValue));
      }
    } else {
      onlyOnLeft.put(leftKey, leftValue);
    }
  }
}
 
开发者ID:antlr,项目名称:codebuff,代码行数:17,代码来源:Maps.java

示例5: describeMismatchSafely

import com.google.common.collect.MapDifference.ValueDifference; //导入依赖的package包/类
protected void describeMismatchSafely(String prefix, MapDifference<TestHistoryDifferenceKey, Collection<TestHistoryDifferenceDescription>> difference, Description mismatchDescription) {
	appendIfNonEmpty(mismatchDescription, prefix, "missing: ", difference.entriesOnlyOnLeft());
	appendIfNonEmpty(mismatchDescription, prefix, "unexpected: ", difference.entriesOnlyOnRight());
	for (Entry<TestHistoryDifferenceKey, ValueDifference<Collection<TestHistoryDifferenceDescription>>> entryDiffering : difference.entriesDiffering().entrySet()) {
		mismatchDescription.appendText(prefix).appendText("differing from expected: ")
				.appendValue(entryDiffering.getKey());
		ValueDifference<Collection<TestHistoryDifferenceDescription>> valueDifference = entryDiffering.getValue();
		Collection<TestHistoryDifferenceDescription> expectedCollection = valueDifference.leftValue();
		Collection<TestHistoryDifferenceDescription> actualCollection = valueDifference.rightValue();
		String newPrefix = prefix + "\t\t";
		if (expectedCollection.size() == 1 && actualCollection.size() == 1) {
			TestHistoryDifferenceDescription expected = Iterables.getOnlyElement(expectedCollection);
			TestHistoryDifferenceDescription actual = Iterables.getOnlyElement(actualCollection);
			describeMismatchSafely(newPrefix, expected, actual, mismatchDescription);
		} else {
			mismatchDescription.appendText(newPrefix).appendText("expected: ").appendValue(valueDifference.leftValue());
			mismatchDescription.appendText(newPrefix).appendText("actual: ").appendValue(valueDifference.rightValue());
		}
	}
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:21,代码来源:TestHistoryDifferenceCollectionMatcher.java

示例6: doDifference

import com.google.common.collect.MapDifference.ValueDifference; //导入依赖的package包/类
private static <K, V> void doDifference(
    Map<? extends K, ? extends V> left, Map<? extends K, ? extends V> right,
    Equivalence<? super V> valueEquivalence,
    Map<K, V> onlyOnLeft, Map<K, V> onlyOnRight, Map<K, V> onBoth,
    Map<K, MapDifference.ValueDifference<V>> differences) {
  for (Entry<? extends K, ? extends V> entry : left.entrySet()) {
    K leftKey = entry.getKey();
    V leftValue = entry.getValue();
    if (right.containsKey(leftKey)) {
      V rightValue = onlyOnRight.remove(leftKey);
      if (valueEquivalence.equivalent(leftValue, rightValue)) {
        onBoth.put(leftKey, leftValue);
      } else {
        differences.put(
            leftKey, ValueDifferenceImpl.create(leftValue, rightValue));
      }
    } else {
      onlyOnLeft.put(leftKey, leftValue);
    }
  }
}
 
开发者ID:cplutte,项目名称:bts,代码行数:22,代码来源:Maps.java

示例7: parseSection

import com.google.common.collect.MapDifference.ValueDifference; //导入依赖的package包/类
private SectionParsingResult parseSection(List<String> lines)
{
    Map<String, String> properties = newHashMap();
    lines.stream().forEach((String line) -> {
        if (lineHasProperties(line)) {
            Map<String, String> lineProperties = parseLineProperties(line);
            Map<String, ValueDifference<String>> difference = difference(properties, lineProperties).entriesDiffering();
            checkState(difference.isEmpty(), "Different properties: ", difference);
            properties.putAll(lineProperties);
        }
    });

    List<String> contentFiltered = filterContent(lines);
    Optional<String> sectionName = Optional.ofNullable(properties.get(SECTION_NAME_KEY));
    return new SectionParsingResult(sectionName, lines, properties, contentFiltered);
}
 
开发者ID:prestodb,项目名称:tempto,代码行数:17,代码来源:AnnotatedFileParser.java

示例8: scheduleCleanerJobIfNecessary

import com.google.common.collect.MapDifference.ValueDifference; //导入依赖的package包/类
/**
 * This method has been copied from org.eclipse.xtext.builder.preferences.BuilderPreferencePage.
 */
private void scheduleCleanerJobIfNecessary(IPreferencePageContainer preferencePageContainer) {
	Map<String, ValueDifference<String>> changes = getPreferenceChanges();
	for (String key : changes.keySet()) {
		if (key.matches("^" + CompilerProperties.OUTPUT_PREFERENCE_TAG + "\\.\\w+\\."
				+ CompilerProperties.OUTPUT_PREFERENCE_TAG + "$")) {
			ValueDifference<String> difference = changes.get(key);
			scheduleCleanerJob(preferencePageContainer, difference.rightValue());
		}
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:14,代码来源:N4JSBuilderPreferencePage.java

示例9: populateCompilerConfiguration

import com.google.common.collect.MapDifference.ValueDifference; //导入依赖的package包/类
/**
 * @param outputName
 *            the output name that identifies the output configuration but in our case also the registered compiler.
 * @param compilerDescriptor
 *            the compiler descriptor holding the values either stored last time this details page was used or the
 *            default values for the compiler
 */
public void populateCompilerConfiguration(String outputName, T compilerDescriptor) {
	// defaults
	preferenceInitializer.initialize(scopedAccessor);

	boolean initialLoad = false;

	ComponentDescriptor currentlyStoredCompilerDescriptor = compilerDescriptor
			.getCurrentlyStoredComponentDescriptor();
	if (currentlyStoredCompilerDescriptor == null) {
		currentlyStoredCompilerDescriptor = compilerDescriptor; // default configuration
		initialLoad = true;
	}

	Map<String, String> originalSettings = currentlyStoredCompilerDescriptor.fillMap(outputName);

	IPreferenceStore preferenceStore = getPreferenceStore();
	// populate
	// use a copy here has we don't want to change the default values provided by the registered compilers
	@SuppressWarnings("unchecked")
	T newCompilerDescriptor = (T) compilerDescriptor.copy();
	for (IComponentProperties<T> prop : getComponentPropertiesValues()) {
		if (prop.getType() == Boolean.class) {
			prop.setValueInCompilerDescriptor(newCompilerDescriptor, outputName,
					preferenceStore.getBoolean(prop.getKey(outputName)));
		} else {
			prop.setValueInCompilerDescriptor(newCompilerDescriptor, outputName,
					preferenceStore.getString(prop.getKey(outputName)));
		}
	}

	Map<String, String> currentSettings = newCompilerDescriptor.fillMap(outputName);

	Map<String, ValueDifference<String>> changes = getPreferenceChanges(originalSettings, currentSettings);

	if (!initialLoad) {
		compilerDescriptor.setChanges(changes);
	}
	compilerDescriptor.setCurrentlyStoredComponentDescriptor(newCompilerDescriptor);
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:47,代码来源:AbstractN4JSPreferenceStoreAccessor.java

示例10: MapDifferenceImpl

import com.google.common.collect.MapDifference.ValueDifference; //导入依赖的package包/类
MapDifferenceImpl(
    Map<K, V> onlyOnLeft,
    Map<K, V> onlyOnRight,
    Map<K, V> onBoth,
    Map<K, ValueDifference<V>> differences) {
  this.onlyOnLeft = unmodifiableMap(onlyOnLeft);
  this.onlyOnRight = unmodifiableMap(onlyOnRight);
  this.onBoth = unmodifiableMap(onBoth);
  this.differences = unmodifiableMap(differences);
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:11,代码来源:Maps.java

示例11: equals

import com.google.common.collect.MapDifference.ValueDifference; //导入依赖的package包/类
@Override
public boolean equals(@Nullable Object object) {
  if (object instanceof MapDifference.ValueDifference) {
    MapDifference.ValueDifference<?> that = (MapDifference.ValueDifference<?>) object;
    return Objects.equal(this.left, that.leftValue())
        && Objects.equal(this.right, that.rightValue());
  }
  return false;
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:10,代码来源:Maps.java

示例12: SortedMapDifferenceImpl

import com.google.common.collect.MapDifference.ValueDifference; //导入依赖的package包/类
SortedMapDifferenceImpl(
    SortedMap<K, V> onlyOnLeft,
    SortedMap<K, V> onlyOnRight,
    SortedMap<K, V> onBoth,
    SortedMap<K, ValueDifference<V>> differences) {
  super(onlyOnLeft, onlyOnRight, onBoth, differences);
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:8,代码来源:Maps.java

示例13: handleTepIpsUpdateEvent

import com.google.common.collect.MapDifference.ValueDifference; //导入依赖的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

示例14: MapDifferenceImpl

import com.google.common.collect.MapDifference.ValueDifference; //导入依赖的package包/类
MapDifferenceImpl(
                 Map<K, V> onlyOnLeft,
                 Map<K, V> onlyOnRight,
                 Map<K, V> onBoth,
                 Map<K, ValueDifference<V>> differences) {
  this.onlyOnLeft = unmodifiableMap(onlyOnLeft);
  this.onlyOnRight = unmodifiableMap(onlyOnRight);
  this.onBoth = unmodifiableMap(onBoth);
  this.differences = unmodifiableMap(differences);
}
 
开发者ID:antlr,项目名称:codebuff,代码行数:11,代码来源:Maps.java

示例15: equals

import com.google.common.collect.MapDifference.ValueDifference; //导入依赖的package包/类
@Override
    public boolean equals(@Nullable Object object) {
      if (object instanceof MapDifference.ValueDifference) {
        MapDifference.ValueDifference<?> that = (MapDifference.ValueDifference<?>) object;
        return Objects.equal(this.left, that.leftValue())
&& Objects.equal(this.right, that.rightValue());
      }
      return false;
    }
 
开发者ID:antlr,项目名称:codebuff,代码行数:10,代码来源:Maps.java


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