use of com.google.common.collect.MapDifference.ValueDifference in project sonarlint-core by SonarSource.
the class PluginsUpdateChecker method checkForUpdates.
public void checkForUpdates(DefaultStorageUpdateCheckResult result, List<SonarAnalyzer> pluginList) {
PluginReferences serverPluginReferences = pluginReferenceDownloader.fetchPlugins(pluginList);
PluginReferences storagePluginReferences = storageReader.readPluginReferences();
Map<String, String> serverPluginHashes = serverPluginReferences.getReferenceList().stream().collect(Collectors.toMap(PluginReference::getKey, PluginReference::getHash));
Map<String, String> storagePluginHashes = storagePluginReferences.getReferenceList().stream().collect(Collectors.toMap(PluginReference::getKey, PluginReference::getHash));
MapDifference<String, String> pluginDiff = Maps.difference(storagePluginHashes, serverPluginHashes);
if (!pluginDiff.areEqual()) {
for (Map.Entry<String, String> entry : pluginDiff.entriesOnlyOnLeft().entrySet()) {
result.appendToChangelog(String.format("Plugin '%s' removed", entry.getKey()));
}
for (Map.Entry<String, String> entry : pluginDiff.entriesOnlyOnRight().entrySet()) {
result.appendToChangelog("Plugin '" + entry.getKey() + "' added");
}
for (Map.Entry<String, ValueDifference<String>> entry : pluginDiff.entriesDiffering().entrySet()) {
result.appendToChangelog("Plugin '" + entry.getKey() + "' updated");
}
}
}
use of com.google.common.collect.MapDifference.ValueDifference in project sonarlint-core by SonarSource.
the class QualityProfilesUpdateChecker method checkForUpdates.
public void checkForUpdates(DefaultStorageUpdateCheckResult result) {
QProfiles serverQualityProfiles = qualityProfilesDownloader.fetchQualityProfiles();
QProfiles storageQProfiles = storageReader.readQProfiles();
Map<String, QProfile> serverPluginHashes = serverQualityProfiles.getQprofilesByKeyMap();
Map<String, QProfile> storagePluginHashes = storageQProfiles.getQprofilesByKeyMap();
MapDifference<String, QProfile> pluginDiff = Maps.difference(storagePluginHashes, serverPluginHashes);
if (!pluginDiff.areEqual()) {
for (Map.Entry<String, QProfile> entry : pluginDiff.entriesOnlyOnLeft().entrySet()) {
result.appendToChangelog(String.format("Quality profile '%s' for language '%s' removed", entry.getValue().getName(), entry.getValue().getLanguageName()));
}
for (Map.Entry<String, QProfile> entry : pluginDiff.entriesOnlyOnRight().entrySet()) {
result.appendToChangelog(String.format("Quality profile '%s' for language '%s' added", entry.getValue().getName(), entry.getValue().getLanguageName()));
}
for (Map.Entry<String, ValueDifference<QProfile>> entry : pluginDiff.entriesDiffering().entrySet()) {
result.appendToChangelog(String.format("Quality profile '%s' for language '%s' updated", entry.getValue().rightValue().getName(), entry.getValue().rightValue().getLanguageName()));
}
}
}
use of com.google.common.collect.MapDifference.ValueDifference in project netvirt by opendaylight.
the class TunnelUnderlayNetworkChangeListener method handleTepIpsUpdateEvent.
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);
}
}
use of com.google.common.collect.MapDifference.ValueDifference in project n4js by eclipse.
the class AbstractN4JSPreferenceStoreAccessor method populateCompilerConfiguration.
/**
* @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) {
// default configuration
currentlyStoredCompilerDescriptor = compilerDescriptor;
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);
}
use of com.google.common.collect.MapDifference.ValueDifference in project n4js by eclipse.
the class AbstractN4JSPreferencePage method getPreferenceChanges.
/**
* @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. This map contains the changes of all registered compilers
*/
public Map<String, ValueDifference<String>> getPreferenceChanges() {
if (entriesDiffering == null) {
for (Triple<String, String, DESCR_TYPE> compiler : components) {
DESCR_TYPE compilerDescriptor = compiler.getThird();
String outputName = compiler.getFirst();
boolean initialLoad = false;
@SuppressWarnings("unchecked") DESCR_TYPE currentlyStoredCompilerDescriptor = (DESCR_TYPE) compilerDescriptor.getCurrentlyStoredComponentDescriptor();
if (currentlyStoredCompilerDescriptor == null) {
// default configuration
currentlyStoredCompilerDescriptor = compilerDescriptor;
initialLoad = true;
}
Map<String, String> originalSettings = currentlyStoredCompilerDescriptor.fillMap(outputName);
List<IPreferenceStore> preferenceStores = field.getPreferenceStores();
// populate
// use a copy here has we don't want to change the default values provided by the registered compilers
@SuppressWarnings("unchecked") DESCR_TYPE newCompilerDescriptor = (DESCR_TYPE) compilerDescriptor.copy();
for (IPreferenceStore preferenceStore : preferenceStores) {
setDescriptorValuesFromPreferences(preferenceStore, outputName, newCompilerDescriptor);
}
Map<String, String> currentSettings = newCompilerDescriptor.fillMap(outputName);
Map<String, ValueDifference<String>> changes = getPreferenceChanges(originalSettings, currentSettings);
if (!initialLoad) {
compilerDescriptor.setChanges(changes);
}
compilerDescriptor.setCurrentlyStoredComponentDescriptor(newCompilerDescriptor);
}
entriesDiffering = new HashMap<>();
for (Triple<String, String, DESCR_TYPE> compiler : components) {
entriesDiffering.putAll(compiler.getThird().getChanges());
}
}
return entriesDiffering;
}
Aggregations