List of usage examples for com.google.common.collect Maps difference
public static <K, V> SortedMapDifference<K, V> difference(SortedMap<K, ? extends V> left, Map<? extends K, ? extends V> right)
From source file:org.apache.cassandra.schema.Tables.java
MapDifference<String, CFMetaData> diff(Tables other) {
return Maps.difference(tables, other.tables);
}
From source file:com.github.jcustenborder.kafka.connect.utils.GenericAssertions.java
public static void assertMap(Map<String, ?> expected, Map<String, ?> actual, String message) { if (null == expected && null == actual) { return;/*from w ww . j a v a 2 s .c o m*/ } String prefix = Strings.isNullOrEmpty(message) ? "" : message + ": "; assertNotNull(expected, prefix + "expected cannot be null"); assertNotNull(actual, prefix + "actual cannot be null"); MapDifference<String, ?> mapDifference = Maps.difference(expected, actual); assertTrue(mapDifference.areEqual(), new MapDifferenceSupplier(mapDifference, prefix)); }
From source file:org.wso2.carbon.governance.comparator.utils.WSDLComparisonUtils.java
public static boolean isDiffrentMessages(Message left, Message right) { if (left.getQName().equals(right.getQName())) { Map<String, Part> leftParts = left.getParts(); Map<String, Part> rightParts = right.getParts(); MapDifference mapDiff = Maps.difference(leftParts, rightParts); if (mapDiff.areEqual()) { return false; } else {// w ww. jav a 2 s . c o m Map<String, MapDifference.ValueDifference<Part>> difference = mapDiff.entriesDiffering(); for (MapDifference.ValueDifference<Part> diff : difference.values()) { if (isDiffrentParts(diff.leftValue(), diff.rightValue())) { return true; } } } } return false; }
From source file:org.opendaylight.sxp.route.core.RouteReactorImpl.java
@Override public ListenableFuture<Void> updateRouting(@Nullable final SxpClusterRoute oldRoute, @Nullable final SxpClusterRoute newRoute) { final Map<IpAddress, RoutingDefinition> oldDefinitions = new HashMap<>(); final Map<IpAddress, RoutingDefinition> newDefinitions = new HashMap<>(); final List<RoutingDefinition> outcomingRouteDefinitions = new ArrayList<>(); fillDefinitionsSafely(oldRoute, oldDefinitions); fillDefinitionsSafely(newRoute, newDefinitions); final MapDifference<IpAddress, RoutingDefinition> routingDifference = Maps.difference(oldDefinitions, newDefinitions);/*from w w w . ja v a 2 s. c o m*/ // ---------------------------- // ROUTE UPDATE STRATEGY: // 1. remove all deleted routes // 2. remove all changed routes // 3. add all changed routes // 4. add all added routes // ---------------------------- // 1 processDeleted(routingDifference, outcomingRouteDefinitions); // 2+3 processUpdated(routingDifference, outcomingRouteDefinitions); // 4 processAdded(routingDifference, outcomingRouteDefinitions); collectUnchanged(routingDifference, outcomingRouteDefinitions); // update DS/operational final SxpClusterRoute sxpClusterRoute = new SxpClusterRouteBuilder() .setRoutingDefinition(outcomingRouteDefinitions).build(); return datastoreAccess.put(SxpClusterRouteManager.SXP_CLUSTER_ROUTE_CONFIG_PATH, sxpClusterRoute, LogicalDatastoreType.OPERATIONAL); }
From source file:edu.mit.streamjit.impl.compiler2.ActorGroup.java
public void remove(Actor a) { assert actors.contains(a) : a; actors = ImmutableSortedSet.copyOf(Sets.difference(actors, ImmutableSet.of(a))); schedule = ImmutableMap.copyOf(Maps.difference(schedule, ImmutableMap.of(a, 0)).entriesOnlyOnLeft()); }
From source file:com.thinkbiganalytics.metadata.rest.model.nifi.NiFiFlowCacheSync.java
public Map<String, NiFiFlowCacheConnectionData> getConnectionIdToConnectionUpdatedSinceLastSync( Map<String, String> latestConnectionIdToNameMap, Map<String, NiFiFlowCacheConnectionData> latestConnectionDataMap) { MapDifference<String, String> diff = Maps.difference(snapshot.getConnectionIdToConnectionName(), latestConnectionIdToNameMap); Map<String, NiFiFlowCacheConnectionData> differences = new HashMap<>(); Map<String, String> diffs = diff.entriesOnlyOnRight(); if (diffs != null && !diffs.isEmpty()) { for (String connId : diffs.keySet()) { differences.put(connId, latestConnectionDataMap.get(connId)); }/*from w ww .j a v a 2 s . com*/ } Set<String> updates = diff.entriesDiffering().keySet(); if (updates != null) { for (String key : updates) { differences.put(key, latestConnectionDataMap.get(key)); } } return differences; }
From source file:org.apache.cassandra.schema.Views.java
MapDifference<String, ViewDefinition> diff(Views other) {
return Maps.difference(views, other.views);
}
From source file:org.sonar.server.qualityprofile.QProfileComparison.java
private void compareActivationParams(DbSession session, ActiveRuleDto leftRule, ActiveRuleDto rightRule, QProfileComparisonResult result) { RuleKey key = leftRule.getKey().ruleKey(); Map<String, String> leftParams = paramDtoToMap( dbClient.activeRuleDao().selectParamsByActiveRuleId(session, leftRule.getId())); Map<String, String> rightParams = paramDtoToMap( dbClient.activeRuleDao().selectParamsByActiveRuleId(session, rightRule.getId())); if (leftParams.equals(rightParams) && leftRule.getSeverityString().equals(rightRule.getSeverityString())) { result.same.put(key, leftRule);// w w w .j ava2 s . co m } else { ActiveRuleDiff diff = new ActiveRuleDiff(); diff.leftSeverity = leftRule.getSeverityString(); diff.rightSeverity = rightRule.getSeverityString(); diff.paramDifference = Maps.difference(leftParams, rightParams); result.modified.put(key, diff); } }
From source file:org.apache.cassandra.schema.Types.java
MapDifference<ByteBuffer, UserType> diff(Types other) {
return Maps.difference(types, other.types);
}
From source file:org.jfrog.bamboo.builder.GradleInitScriptHelper.java
public ConfigurationPathHolder createAndGetGradleInitScriptPath(String dependenciesDir, GradleBuildContext buildContext, BuildLogger logger, String scriptTemplate, Map<String, String> taskEnv, Map<String, String> generalEnv) { long selectedServerId = buildContext.getArtifactoryServerId(); if (selectedServerId != -1) { //Using "getInstance()" since the field must be transient ServerConfig serverConfig = serverConfigManager.getServerConfigById(selectedServerId); if (serverConfig == null) { String warningMessage = "Found an ID of a selected Artifactory server configuration (" + selectedServerId/*from www. j ava2 s.c o m*/ + ") but could not find a matching configuration. Build info collection is disabled."; logger.addBuildLogHeader(warningMessage, true); log.warn(warningMessage); return null; } else { String normalizedPath = FilenameUtils.separatorsToUnix(dependenciesDir); scriptTemplate = scriptTemplate.replace("${pluginLibDir}", normalizedPath); try { File buildProps = File.createTempFile("buildinfo", "properties"); ArtifactoryClientConfiguration configuration = createClientConfiguration(buildContext, serverConfig, taskEnv); // Add Bamboo build variables MapDifference<String, String> buildVarDifference = Maps.difference(generalEnv, System.getenv()); Map<String, String> filteredBuildVarDifferences = buildVarDifference.entriesOnlyOnLeft(); IncludeExcludePatterns patterns = new IncludeExcludePatterns( buildContext.getEnvVarsIncludePatterns(), buildContext.getEnvVarsExcludePatterns()); configuration.info.addBuildVariables(filteredBuildVarDifferences, patterns); configuration.setPropertiesFile(buildProps.getAbsolutePath()); configuration.persistToPropertiesFile(); File tempInitScript = File.createTempFile("artifactory.init.script", "gradle"); FileUtils.writeStringToFile(tempInitScript, scriptTemplate, "utf-8"); if (buildContext.isPublishBuildInfo()) { this.context.getBuildResult().getCustomBuildData() .put(BUILD_RESULT_COLLECTION_ACTIVATED_PARAM, "true"); this.context.getBuildResult().getCustomBuildData().put(BUILD_RESULT_SELECTED_SERVER_PARAM, serverConfig.getUrl()); this.context.getBuildResult().getCustomBuildData().put(BUILD_RESULT_RELEASE_ACTIVATED_PARAM, String.valueOf( buildContext.releaseManagementContext.isActivateReleaseManagement())); } return new ConfigurationPathHolder(tempInitScript.getCanonicalPath(), buildProps.getCanonicalPath()); } catch (IOException e) { log.warn("An error occurred while creating the gradle build info init script. " + "Build-info task will not be added.", e); } } } return null; }