本文整理汇总了Java中java.util.Map.equals方法的典型用法代码示例。如果您正苦于以下问题:Java Map.equals方法的具体用法?Java Map.equals怎么用?Java Map.equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.Map
的用法示例。
在下文中一共展示了Map.equals方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setColorSchemes
import java.util.Map; //导入方法依赖的package包/类
/**
* @param colorScheme
* the colorScheme to set
*/
public void setColorSchemes(Map<String, ColorScheme> colorSchemes, String activeColorSchemeName) {
boolean changed = false;
ColorScheme oldActiveScheme = getActiveColorScheme();
if (!colorSchemes.equals(this.colorSchemes)) {
this.colorSchemes = colorSchemes;
changed = true;
}
if (!oldActiveScheme.equals(colorSchemes.get(activeColorSchemeName))) {
setActiveScheme(activeColorSchemeName);
changed = true;
}
if (changed) {
firePlotConfigurationChanged(new PlotConfigurationChangeEvent(this, getActiveColorScheme()));
}
}
示例2: mergeFromMasterAndPublishBranch
import java.util.Map; //导入方法依赖的package包/类
private void mergeFromMasterAndPublishBranch(Namespace parentNamespace, Namespace childNamespace,
Map<String, String> parentNamespaceItems,
String releaseName, String releaseComment,
String operator, Release masterPreviousRelease,
Release parentRelease, boolean isEmergencyPublish) {
//create release for child namespace
Map<String, String> childReleaseConfiguration = getNamespaceReleaseConfiguration(childNamespace);
Map<String, String> parentNamespaceOldConfiguration = masterPreviousRelease == null ?
null : gson.fromJson(masterPreviousRelease.getConfigurations(),
GsonType.CONFIG);
Map<String, String> childNamespaceToPublishConfigs =
calculateChildNamespaceToPublishConfiguration(parentNamespaceOldConfiguration,
parentNamespaceItems,
childNamespace);
//compare
if (!childNamespaceToPublishConfigs.equals(childReleaseConfiguration)) {
branchRelease(parentNamespace, childNamespace, releaseName, releaseComment,
childNamespaceToPublishConfigs, parentRelease.getId(), operator,
ReleaseOperation.MASTER_NORMAL_RELEASE_MERGE_TO_GRAY, isEmergencyPublish);
}
}
示例3: main
import java.util.Map; //导入方法依赖的package包/类
public static void main(String[] args) {
boolean test;
/* synchronizedList test */
List list = Collections.synchronizedList(new ArrayList());
list.add(list);
test = list.equals(list);
assertTrue(test);
list.remove(list);
/* synchronizedSet test */
Set s = Collections.synchronizedSet(new HashSet());
s.add(s);
test = s.equals(s);
assertTrue(test);
/* synchronizedMap test */
Map m = Collections.synchronizedMap(new HashMap());
test = m.equals(m);
assertTrue(test);
}
示例4: assertExceptions
import java.util.Map; //导入方法依赖的package包/类
@SafeVarargs
private static void assertExceptions(String methodName, Class<? extends Exception>... expectedExceptions)
{
ThriftMethodMetadata metadata = new ThriftMethodMetadata(getMethod(methodName), new ThriftCatalog());
Map<Short, Type> actualIdMap = new TreeMap<>();
Map<Short, Type> expectedIdMap = new TreeMap<>();
for (Map.Entry<Short, ThriftType> entry : metadata.getExceptions().entrySet()) {
actualIdMap.put(entry.getKey(), entry.getValue().getJavaType());
}
short expectedId = 1;
for (Class<? extends Exception> expectedException : expectedExceptions) {
expectedIdMap.put(expectedId, expectedException);
expectedId++;
}
// string comparison produces more useful failure message (and is safe, given the types)
if (!actualIdMap.equals(expectedIdMap)) {
assertEquals(actualIdMap.toString(), expectedIdMap.toString());
}
}
示例5: applyContentInResponse
import java.util.Map; //导入方法依赖的package包/类
/**
* Applies the variables, messages, or update rules in a start or getVars response.
*
* @param response The response containing content.
* @param alwaysApply Always apply the content regardless of whether the content changed.
*/
private static void applyContentInResponse(JSONObject response, boolean alwaysApply) {
Map<String, Object> values = JsonConverter.mapFromJsonOrDefault(
response.optJSONObject(Constants.Keys.VARS));
Map<String, Object> messages = JsonConverter.mapFromJsonOrDefault(
response.optJSONObject(Constants.Keys.MESSAGES));
List<Map<String, Object>> updateRules = JsonConverter.listFromJsonOrDefault(
response.optJSONArray(Constants.Keys.UPDATE_RULES));
List<Map<String, Object>> eventRules = JsonConverter.listFromJsonOrDefault(
response.optJSONArray(Constants.Keys.EVENT_RULES));
Map<String, Object> regions = JsonConverter.mapFromJsonOrDefault(
response.optJSONObject(Constants.Keys.REGIONS));
List<Map<String, Object>> variants = JsonConverter.listFromJsonOrDefault(
response.optJSONArray(Constants.Keys.VARIANTS));
if (alwaysApply
|| !values.equals(VarCache.getDiffs())
|| !messages.equals(VarCache.getMessageDiffs())
|| !updateRules.equals(VarCache.getUpdateRuleDiffs())
|| !eventRules.equals(VarCache.getEventRuleDiffs())
|| !regions.equals(VarCache.regions())) {
VarCache.applyVariableDiffs(values, messages, updateRules,
eventRules, regions, variants);
}
}
示例6: saveConfiguration
import java.util.Map; //导入方法依赖的package包/类
public void saveConfiguration() {
// próba odczytania configu
Map<String, String> old = loadConfigFromFile(configFileName);
// jeżeli się nie zmienił to nie robimy zmian
if (old != null && !old.isEmpty() && old.equals(this.config)) {
return;
}
try (FileOutputStream fo = new FileOutputStream(configFileName)) {
PrintStream out = new PrintStream(fo);
Set<Map.Entry<String, String>> set = this.config.entrySet();
set.stream().map((element) -> {
out.print(element.getKey());
return element;
}).forEach((element) -> {
out.print("=");
out.println(element.getValue());
});
} catch (IOException ex) {
Logger.getLogger(ConfigurationManager.class.getName()).log(Level.SEVERE, null, ex);
}
}
示例7: getHeaders
import java.util.Map; //导入方法依赖的package包/类
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
Map<String, String> headers = super.getHeaders();
if (headers == null || headers.equals(Collections.emptyMap())) {
headers = new HashMap<String, String>();
}
if (apiHeaders != null && !apiHeaders.equals(Collections.emptyMap())) {
headers.putAll(apiHeaders);
}
if(contentType != null) {
headers.put("Content-Type", contentType);
}
return headers;
}
示例8: compare
import java.util.Map; //导入方法依赖的package包/类
public static boolean compare(Map<?, ?> map1, Map<?, ?> map2) {
boolean result = true;
if (map1 == map2) {
return true;
}
if (map1.equals(map2)) {
return true;
}
if (map1.size() != map2.size()) {
return false;
}
//TODO compare(Map map1, Map map2)
result = false;
return result;
}
示例9: rowDifference
import java.util.Map; //导入方法依赖的package包/类
private static ResultRowDifference rowDifference(Map<String, Object> actualRow,
Map<String, Object> expectedRow) {
if (actualRow.equals(expectedRow)) {
return ResultRowDifference.empty();
}
return computeDifference(actualRow, expectedRow);
}
示例10: getHeaders
import java.util.Map; //导入方法依赖的package包/类
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
Map<String, String> headers = super.getHeaders();
if (headers == null || headers.equals(Collections.emptyMap())) {
headers = new HashMap<String, String>();
}
if (apiHeaders != null && !apiHeaders.equals(Collections.emptyMap())) {
headers.putAll(apiHeaders);
}
if(contentType != null) {
headers.put("Content-Type", contentType);
}
return headers;
}
示例11: upgradeMetaData
import java.util.Map; //导入方法依赖的package包/类
/**
* Elasticsearch 2.0 removed several deprecated features and as well as support for Lucene 3.x. This method calls
* {@link MetaDataIndexUpgradeService} to makes sure that indices are compatible with the current version. The
* MetaDataIndexUpgradeService might also update obsolete settings if needed.
* Allows upgrading global custom meta data via {@link MetaDataUpgrader#customMetaDataUpgraders}
*
* @return input <code>metaData</code> if no upgrade is needed or an upgraded metaData
*/
static MetaData upgradeMetaData(MetaData metaData,
MetaDataIndexUpgradeService metaDataIndexUpgradeService,
MetaDataUpgrader metaDataUpgrader) throws Exception {
// upgrade index meta data
boolean changed = false;
final MetaData.Builder upgradedMetaData = MetaData.builder(metaData);
for (IndexMetaData indexMetaData : metaData) {
IndexMetaData newMetaData = metaDataIndexUpgradeService.upgradeIndexMetaData(indexMetaData,
Version.CURRENT.minimumIndexCompatibilityVersion());
changed |= indexMetaData != newMetaData;
upgradedMetaData.put(newMetaData, false);
}
// collect current customs
Map<String, MetaData.Custom> existingCustoms = new HashMap<>();
for (ObjectObjectCursor<String, MetaData.Custom> customCursor : metaData.customs()) {
existingCustoms.put(customCursor.key, customCursor.value);
}
// upgrade global custom meta data
Map<String, MetaData.Custom> upgradedCustoms = metaDataUpgrader.customMetaDataUpgraders.apply(existingCustoms);
if (upgradedCustoms.equals(existingCustoms) == false) {
existingCustoms.keySet().forEach(upgradedMetaData::removeCustom);
for (Map.Entry<String, MetaData.Custom> upgradedCustomEntry : upgradedCustoms.entrySet()) {
upgradedMetaData.putCustom(upgradedCustomEntry.getKey(), upgradedCustomEntry.getValue());
}
changed = true;
}
return changed ? upgradedMetaData.build() : metaData;
}
示例12: verifyScope
import java.util.Map; //导入方法依赖的package包/类
private static void verifyScope(Options options, Map<String, List<String>> scope)
throws SecureLoginVerificationException {
if (options.isPasswordChange()) {
boolean properScope = scope.get("mode").contains("change") && scope.containsKey("to") && scope.size() == 2;
if (!properScope) {
throw new SecureLoginVerificationException(SecureLoginVerificationFailure.NOT_CHANGE_TOKEN_MODE);
}
} else if (!scope.isEmpty() && !scope.equals(options.getScope())){
throw new SecureLoginVerificationException(SecureLoginVerificationFailure.INVALID_SCOPE);
}
}
示例13: buildLsUpdate
import java.util.Map; //导入方法依赖的package包/类
/**
* Builds the LsUpdate for flooding.
*
* @param txList list contains LSAs
* @return list of LsUpdate instances
*/
private List buildLsUpdate(Map<String, OspfLsa> txList) {
List<LsUpdate> lsUpdateList = new ArrayList<>();
ListIterator itr = new ArrayList(txList.keySet()).listIterator();
while (itr.hasNext()) {
LsUpdate lsupdate = new LsUpdate();
// seting OSPF Header
lsupdate.setOspfVer(OspfUtil.OSPF_VERSION);
lsupdate.setOspftype(OspfPacketType.LSUPDATE.value());
lsupdate.setRouterId(ospfArea.routerId());
lsupdate.setAreaId(ospfArea.areaId());
lsupdate.setAuthType(OspfUtil.NOT_ASSIGNED);
lsupdate.setAuthentication(OspfUtil.NOT_ASSIGNED);
lsupdate.setOspfPacLength(OspfUtil.NOT_ASSIGNED); // to calculate packet length
lsupdate.setChecksum(OspfUtil.NOT_ASSIGNED);
//limit to mtu
int currentLength = OspfUtil.OSPF_HEADER_LENGTH + OspfUtil.FOUR_BYTES;
int maxSize = ospfInterface.mtu() -
OspfUtil.LSA_HEADER_LENGTH; // subtract a normal IP header.
int noLsa = 0;
while (itr.hasNext()) {
String key = (String) itr.next();
OspfLsa lsa = txList.get(key);
if ((lsa.age() + OspfParameters.INFTRA_NS_DELAY) >= OspfParameters.MAXAGE) {
((LsaHeader) lsa.lsaHeader()).setAge(OspfParameters.MAXAGE);
} else {
((LsaHeader) lsa.lsaHeader()).setAge(lsa.age() + OspfParameters.INFTRA_NS_DELAY);
}
if ((currentLength + ((LsaHeader) lsa.lsaHeader()).lsPacketLen()) >= maxSize) {
itr.previous();
break;
}
log.debug("FloodingTimer::LSA Type::{}, Header: {}, LSA: {}", lsa.getOspfLsaType(),
lsa.lsaHeader(), lsa);
if (lsa != null) {
lsupdate.addLsa(lsa);
noLsa++;
currentLength = currentLength + ((LsaHeader) lsa.lsaHeader()).lsPacketLen();
}
log.debug("FloodingTimer::Removing key {}", key);
if (txList.equals(reTxList)) {
reTxList.remove(key);
pendingReTxList.put(key, lsa);
}
}
//set number of lsa's
lsupdate.setNumberOfLsa(noLsa);
lsUpdateList.add(lsupdate);
}
return lsUpdateList;
}
示例14: createEntityManagerFactory
import java.util.Map; //导入方法依赖的package包/类
@Override
public EntityManagerFactory createEntityManagerFactory(Map<String, Object> props) {
synchronized (this) {
if (closed) {
throw new IllegalStateException("The EntityManagerFactoryBuilder for " +
getPUName() + " is no longer valid");
}
}
if (bundle.getState() == Bundle.UNINSTALLED || bundle.getState() == Bundle.INSTALLED
|| bundle.getState() == Bundle.STOPPING) {
// Not sure why but during the TCK tests updated sometimes was
// called for uninstalled bundles
throw new IllegalStateException("The EntityManagerFactoryBuilder for " +
getPUName() + " is no longer valid");
}
Map<String, Object> processedProperties = processProperties(props);
synchronized (this) {
if(processedProperties.equals(activeProps) && emf != null) {
return emf;
}
}
closeEMF();
final EntityManagerFactory toUse = createAndPublishEMF(processedProperties);
return (EntityManagerFactory) Proxy.newProxyInstance(getClass().getClassLoader(),
new Class<?>[] {EntityManagerFactory.class}, new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
if("close".equals(method.getName())) {
// Close the registration as per the spec
closeEMF();
// Do not delegate as the closeEMF call already closes
return null;
}
return method.invoke(toUse, args);
}
});
}
示例15: singleRepositoryMigration
import java.util.Map; //导入方法依赖的package包/类
/**
* Makes sure a legacy {@link GitRepository} is migrated to the modern format.
*/
@Test
public void singleRepositoryMigration() {
final File repoDir0 = new File(tempDir.getRoot(), "legacy");
final File repoDir1 = new File(tempDir.getRoot(), "modern");
final GitRepository repo0 = new GitRepository(proj, repoDir0, V0, commonPool(), 0, Author.SYSTEM);
try {
assertThat(repo0.format()).isSameAs(V0);
// Put some commits into the legacy repo.
for (int i = 1; i < 128; i++) {
repo0.commit(new Revision(i), i * 1000, new Author("user" + rnd() + "@example.com"),
"Summary " + rnd(), "Detail " + rnd(), Markup.PLAINTEXT,
Change.ofTextUpsert("/file_" + rnd() + ".txt", "content " + i)).join();
}
// Build a clone in modern format.
repo0.cloneTo(repoDir1);
final GitRepository repo1 = new GitRepository(proj, repoDir1, commonPool());
try {
assertThat(repo1.format()).isSameAs(V1);
// Make sure all commits are identical.
final List<Commit> commits0 = repo0.history(
Revision.INIT, Revision.HEAD, Repository.ALL_PATH, Integer.MAX_VALUE).join();
final List<Commit> commits1 = repo1.history(
Revision.INIT, Revision.HEAD, Repository.ALL_PATH, Integer.MAX_VALUE).join();
assertThat(commits1).isEqualTo(commits0);
// Make sure all commits are ordered correctly.
for (int i = 0; i < commits0.size(); i++) {
assertThat(commits0.get(i).revision().major()).isEqualTo(i + 1);
}
// Make sure the changes of all commits are identical.
for (Commit c : commits0) {
if (c.revision().major() == 1) {
continue;
}
final Map<String, Change<?>> changes0 = repo0.diff(
c.revision().backward(1), c.revision(), Repository.ALL_PATH).join();
final Map<String, Change<?>> changes1 = repo0.diff(
c.revision().backward(1), c.revision(), Repository.ALL_PATH).join();
if (changes0.equals(changes1)) {
logger.debug("{}: {}", c.revision().major(), changes0);
} else {
logger.warn("{}: {} vs. {}", c.revision().major(), changes0, changes1);
}
assertThat(changes1)
.withFailMessage("mismatching changes for revision %s", c.revision().major())
.isEqualTo(changes0);
}
} finally {
repo1.close();
}
} finally {
repo0.close();
}
}