本文整理汇总了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);
}
}
}
示例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;
};
}
示例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);
}
}
}
});
}
示例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);
}
}
}
示例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());
}
}
}
示例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);
}
}
}
示例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);
}
示例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());
}
}
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
}
示例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);
}
示例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;
}