本文整理汇总了Java中com.google.common.collect.MapDifference.areEqual方法的典型用法代码示例。如果您正苦于以下问题:Java MapDifference.areEqual方法的具体用法?Java MapDifference.areEqual怎么用?Java MapDifference.areEqual使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.collect.MapDifference
的用法示例。
在下文中一共展示了MapDifference.areEqual方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findMatchedRows
import com.google.common.collect.MapDifference; //导入方法依赖的package包/类
private List<WebElement> findMatchedRows(List<RowWebElement> matchedRows,
Map<String, String> rowToFind) {
List<WebElement> resultedRows = new ArrayList<WebElement>();
for (RowWebElement rowCandidate : matchedRows) {
Map<String, String> cellsCandidates = cellsFromRow(rowCandidate);
MapDifference<String, String> diff = Maps.difference
(cellsCandidates, rowToFind);
if (diff.areEqual()) {
resultedRows.add(rowCandidate.getRow());
} else if (diff.entriesOnlyOnRight().isEmpty() && diff
.entriesDiffering().isEmpty()) {
resultedRows.add(rowCandidate.getRow());
} else if (rowCandidate.hasSubRows()) {
for (String commonKey : diff.entriesInCommon().keySet()) {
rowToFind.remove(commonKey);
}
return findMatchedRows(getSubRowsFor(rowCandidate), diff
.entriesOnlyOnRight().isEmpty() ? rowToFind : diff
.entriesOnlyOnRight());
}
}
return resultedRows;
}
示例2: doEquivalent
import com.google.common.collect.MapDifference; //导入方法依赖的package包/类
@Override
protected boolean doEquivalent(SolrInputField o1, SolrInputField o2) {
if (o1.getValue() instanceof SolrInputDocument) {
if (!(o2.getValue() instanceof SolrInputDocument)) {
return false;
}
final MapDifference<String, SolrInputField> difference = Maps.difference(
(SolrInputDocument) o1.getValue(),
(SolrInputDocument) o2.getValue(),
this
);
if (!difference.areEqual()) {
return false;
}
} else {
if (o1.getValue() != o2.getValue()) {
return false;
}
}
return true;
}
示例3: getDiff
import com.google.common.collect.MapDifference; //导入方法依赖的package包/类
private boolean getDiff(String captureInstanceName, Map<String, Integer> sourceTableColumnInfo, Map<String, Integer> cdcTableColumnInfo) {
MapDifference<String, Integer> diff = Maps.difference(sourceTableColumnInfo, cdcTableColumnInfo);
if (!diff.areEqual()) {
if (LOG.isTraceEnabled()) {
LOG.trace(
"Detected drift for table {} - new columns: {}, drop columns: {}",
captureInstanceName,
StringUtils.join(diff.entriesOnlyOnLeft().keySet(), ","),
StringUtils.join(diff.entriesOnlyOnRight().keySet(), ",")
);
}
return true;
}
return false;
}
示例4: isDifferent
import com.google.common.collect.MapDifference; //导入方法依赖的package包/类
private boolean isDifferent(Map<String, Fault> left, Map<String, Fault> right) {
if (left != null && right != null && left.size() != right.size()) {
return true;
} else {
MapDifference<String, Fault> mapDiff = Maps.difference(left, right);
if (!mapDiff.areEqual()) {
return true;
} else {
for (String name : mapDiff.entriesInCommon().keySet()) {
if (isDifferent(left.get(name), right.get(name))) {
return true;
}
}
}
}
return false;
}
示例5: equalsTuple
import com.google.common.collect.MapDifference; //导入方法依赖的package包/类
public final boolean equalsTuple(Object oo, boolean print) {
if (oo != null && oo instanceof MapTuple) {
MapTuple t = (MapTuple)oo;
MapDifference<String, Object> diff = Maps.difference(t._values, this._values);
if (diff.areEqual()) {
return true;
} else {
if (print) {
System.err.println(diff);
}
}
}
return false;
}
示例6: assertMapsEqual
import com.google.common.collect.MapDifference; //导入方法依赖的package包/类
static <K, V> void assertMapsEqual(
Map<K, V> expected, Map<K, V> result, Equivalence<V> valueEquivalence) {
MapDifference<K, V> difference = Maps.difference(expected, result, valueEquivalence);
if (!difference.areEqual()) {
StringBuilder builder = new StringBuilder();
builder.append("Maps differ. ");
builder.append("Entries differing: ").append(difference.entriesDiffering()).append("\n");
builder.append("Missing entries: ").append(difference.entriesOnlyOnLeft()).append("\n");
builder.append("Extra entries: ").append(difference.entriesOnlyOnRight()).append("\n");
fail(builder.toString());
}
}
示例7: 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);
}
}
示例8: detectDeclarationChange
import com.google.common.collect.MapDifference; //导入方法依赖的package包/类
private boolean detectDeclarationChange(Definition base, Definition changed) {
// 1. Check Namespaces
Map<String, String> baseNamespaces = base.getNamespaces();
Map<String, String> changedNamespaces = changed.getNamespaces();
MapDifference<String, String> mapDiff = Maps.difference(baseNamespaces, changedNamespaces);
if (!mapDiff.areEqual()) {
return true;
}
// 2. Check QNames
if (isNotEqualAndNotNull(base.getQName(), changed.getQName())) {
return true;
}
// 3. Check TNS
if (isNotEqualAndNotNull(base.getTargetNamespace(), changed.getTargetNamespace())) {
return true;
}
// 4. Check documentation
if (isNotEqualAndNotNull(base.getDocumentationElement(), changed.getDocumentationElement())) {
return true;
}
// 4. Check baseURI
//TODO It seems comparing baseURI is not correct, check again.
// if (isNotEqualAndNotNull(base.getDocumentBaseURI(), changed.getDocumentBaseURI())) {
// return true;
// }
return false;
}
示例9: 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);
}
}
示例10: 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);
}
}
示例11: 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);
}
}
示例12: isModified
import com.google.common.collect.MapDifference; //导入方法依赖的package包/类
boolean isModified(Namespace namespace) {
Release release = releaseService.findLatestActiveRelease(namespace);
List<Item> items = itemService.findItemsWithoutOrdered(namespace.getId());
if (release == null) {
return hasNormalItems(items);
}
Map<String, String> releasedConfiguration = gson.fromJson(release.getConfigurations(), GsonType.CONFIG);
Map<String, String> configurationFromItems = generateConfigurationFromItems(namespace, items);
MapDifference<String, String> difference = Maps.difference(releasedConfiguration, configurationFromItems);
return !difference.areEqual();
}
示例13: handleOvsdbNodeUpdate
import com.google.common.collect.MapDifference; //导入方法依赖的package包/类
/**
* Update transport zones based on local_ips TEP ips mapping to underlay
* networks.<br>
* Deleted local_ips will be removed from the VTEP list of the corresponding
* transport zones.<br>
* Added local_ips will be added to all transport zones currently associated
* with the TEP<br>
* local_ips for whom the underlay network mapping has been changed will be
* updated in the VTEP lists of the corresponding transport zones.
*
* @param origNode
* original OVS node
* @param updatedNode
* updated OVS node
* @param managerNodeId
* uuid of the OVS manager node
*/
public void handleOvsdbNodeUpdate(Node origNode, Node updatedNode, String managerNodeId) {
Map<String,
String> origLocalIpMap = java.util.Optional
.ofNullable(elanBridgeManager.getOpenvswitchOtherConfigMap(origNode, LOCAL_IPS))
.orElse(Collections.emptyMap());
Map<String,
String> updatedLocalIpMap = java.util.Optional
.ofNullable(elanBridgeManager.getOpenvswitchOtherConfigMap(updatedNode, LOCAL_IPS))
.orElse(Collections.emptyMap());
MapDifference<String, String> mapDiff = Maps.difference(origLocalIpMap, updatedLocalIpMap);
if (mapDiff.areEqual()) {
return;
}
java.util.Optional<BigInteger> dpIdOpt = elanBridgeManager.getDpIdFromManagerNodeId(managerNodeId);
if (!dpIdOpt.isPresent()) {
LOG.debug("No DPN id found for node {}", managerNodeId);
return;
}
BigInteger dpId = dpIdOpt.get();
Optional<DPNTEPsInfo> dpnTepsInfoOpt = getDpnTepsInfo(dpId);
if (!dpnTepsInfoOpt.isPresent()) {
LOG.debug("No DPNTEPsInfo found for DPN id {}", dpId);
return;
}
List<TunnelEndPoints> tunnelEndPoints = dpnTepsInfoOpt.get().getTunnelEndPoints();
if (tunnelEndPoints == null || tunnelEndPoints.isEmpty()) {
LOG.debug("No tunnel endpoints defined for DPN id {}", dpId);
return;
}
Set<String> zonePrefixes = new HashSet<>();
Map<String, List<String>> tepTzMap = tunnelEndPoints.stream().collect(Collectors
.toMap(tep -> String.valueOf(tep.getIpAddress().getValue()), this::getTepTransportZoneNames));
LOG.trace("Transport zone prefixes {}", tepTzMap);
WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
handleRemovedLocalIps(mapDiff.entriesOnlyOnLeft(), dpId, zonePrefixes, tepTzMap, tx);
handleChangedLocalIps(mapDiff.entriesDiffering(), dpId, zonePrefixes, tepTzMap, tx);
handleAddedLocalIps(mapDiff.entriesOnlyOnRight(), dpId, zonePrefixes, tx);
tx.submit();
}
示例14: 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;
}