當前位置: 首頁>>代碼示例>>Java>>正文


Java Maps.difference方法代碼示例

本文整理匯總了Java中com.google.common.collect.Maps.difference方法的典型用法代碼示例。如果您正苦於以下問題:Java Maps.difference方法的具體用法?Java Maps.difference怎麽用?Java Maps.difference使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.common.collect.Maps的用法示例。


在下文中一共展示了Maps.difference方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: findDifference

import com.google.common.collect.Maps; //導入方法依賴的package包/類
public AreasMapComparationResult findDifference(Map<Area, ColorModel> previous, Map<Area, ColorModel> current) {
    MapDifference<Area, ColorModel> differences = Maps.difference(previous, current);

    checkDifferencesCount(differences);

    if (isAdded(differences)) {
        return getAdded(differences);
    }
    if (isRemoved(differences)) {
        return getRemoved(differences);
    }
    if (isChanged(differences)) {
        return getChanged(differences);
    }

    return AreasMapComparationResult.ofSame();
}
 
開發者ID:YoungDigitalPlanet,項目名稱:empiria.player,代碼行數:18,代碼來源:AreasMapsComparator.java

示例2: TestDiff

import com.google.common.collect.Maps; //導入方法依賴的package包/類
@Test
public void TestDiff() {
  HashMap<String, Object> map1 = new HashMap<>();
  HashMap<String, Object> map2 = new HashMap<>();
  map1.put("bbbb", "cccc");
  map1.put("xxx", "aaa");
  map2.put("xxx", "aa");
  map2.put("cccc", "bbbb");
  map1.put("dict", ImmutableMap.builder().put("a", 1).put("b", 2)
      .put("em", ImmutableMap.builder().put("c", 3).build()).build());
  map2.put("dict", ImmutableMap.builder().put("a", 1).put("b", 3)
      .put("em", ImmutableMap.builder().put("c", 4).put("d", 5).build()).build());
  MapDifference diff = Maps.difference(map1, map2);
  Map diffMap = new HashMap();
  JsonCompareUtil.getDetailsDiff(map1, map2, diffMap, "");
  Assert.assertTrue(diffMap.containsKey("bbbb"));
  Assert.assertTrue(diffMap.containsKey("xxx"));
  Assert.assertTrue(diffMap.containsKey("cccc"));
  Assert.assertTrue(diffMap.containsKey("dict.b"));
  Assert.assertTrue(diffMap.containsKey("dict.em.c"));
  Assert.assertTrue(diffMap.containsKey("dict.em.d"));
  Assert.assertEquals(6, diffMap.size());
}
 
開發者ID:pinterest,項目名稱:soundwave,代碼行數:24,代碼來源:JsonCompareUtilTest.java

示例3: findMatchedRows

import com.google.common.collect.Maps; //導入方法依賴的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;
}
 
開發者ID:tapack,項目名稱:satisfy,代碼行數:24,代碼來源:BaseTableSteps.java

示例4: roughlyEqual

import com.google.common.collect.Maps; //導入方法依賴的package包/類
private static boolean roughlyEqual(String expectedRaw, String requestedPathRaw) {
    logger.debug("Comparing expected [{}] vs requested [{}]", expectedRaw, requestedPathRaw);
    if(StringUtils.isEmpty(expectedRaw)) {
        logger.debug("False: empty expected");
        return false;
    }
    try {
        UriComponents expected = UriComponentsBuilder.fromUriString(expectedRaw).build();
        UriComponents requested = UriComponentsBuilder.fromUriString(requestedPathRaw).build();

        if(!Objects.equals(expected.getPath(), requested.getPath())) {
            logger.debug("False: expected path [{}] does not match requested path [{}]",
                    expected.getPath(), requested.getPath());
            return false;
        }

        MapDifference<String, List<String>> difference = Maps.difference(expected.getQueryParams(),
                requested.getQueryParams());

        if(difference.entriesDiffering().size() != 0 ||
                difference.entriesOnlyOnLeft().size() != 0 ||
                difference.entriesOnlyOnRight().size() != 1 ||
                difference.entriesOnlyOnRight().get(JWTSecurityService.JWT_PARAM_NAME) == null) {
            logger.debug("False: expected query params [{}] do not match requested query params [{}]", expected.getQueryParams(), requested.getQueryParams());
            return false;
        }

    } catch(Exception e) {
        logger.warn("Exception encountered while comparing paths", e);
        return false;
    }
    return true;
}
 
開發者ID:airsonic,項目名稱:airsonic,代碼行數:34,代碼來源:JWTAuthenticationProvider.java

示例5: isModified

import com.google.common.collect.Maps; //導入方法依賴的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();

}
 
開發者ID:dewey-its,項目名稱:apollo-custom,代碼行數:17,代碼來源:NamespaceUnlockAspect.java

示例6: getPreferenceChanges

import com.google.common.collect.Maps; //導入方法依賴的package包/類
/**
 * @param originalSettings
 *            the settings before applying the values of the form page
 * @param currentSettings
 *            the settings after collecting the values of the form page
 * @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.
 */
private Map<String, ValueDifference<String>> getPreferenceChanges(Map<String, String> originalSettings,
		Map<String, String> currentSettings) {
	MapDifference<String, String> mapDifference = Maps.difference(currentSettings, originalSettings);
	Map<String, ValueDifference<String>> entriesDiffering = mapDifference.entriesDiffering();
	return entriesDiffering;
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:16,代碼來源:AbstractN4JSPreferenceStoreAccessor.java

示例7: getPreferenceChanges

import com.google.common.collect.Maps; //導入方法依賴的package包/類
/**
 * @param originalSettings
 *            the settings before applying the values of the form page
 * @param currentSettings
 *            the settings after collecting the values of the form page
 * @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.
 */
private Map<String, ValueDifference<String>> getPreferenceChanges(Map<String, String> originalSettings,
		Map<String, String> currentSettings) {
	MapDifference<String, String> mapDifference = Maps.difference(currentSettings, originalSettings);
	return mapDifference.entriesDiffering();
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:15,代碼來源:AbstractN4JSPreferencePage.java

示例8: difference

import com.google.common.collect.Maps; //導入方法依賴的package包/類
/**
 * 對兩個Map進行比較,返回MapDifference,然後各種妙用.
 * 
 * 包括key的差集,key的交集,以及key相同但value不同的元素。
 */
public static <K, V> MapDifference<K, V> difference(Map<? extends K, ? extends V> left,
		Map<? extends K, ? extends V> right) {
	return Maps.difference(left, right);
}
 
開發者ID:zhangjunfang,項目名稱:util,代碼行數:10,代碼來源:MapUtil.java


注:本文中的com.google.common.collect.Maps.difference方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。