List of usage examples for java.util Set equals
boolean equals(Object o);
From source file:org.sipfoundry.sipxconfig.cert.JavaKeyStore.java
/** * Compare entries from one keystore with another * * @return false if they differ/*from w ww.j a v a 2 s. c o m*/ */ public boolean isEqual(InputStream bStream) { try { KeyStore b = KeyStore.getInstance(m_type); b.load(bStream, m_password); Set<String> bAliases = toSet(b.aliases()); Set<String> aAliases = toSet(m_store.aliases()); KeyStore.PasswordProtection keyPass = new KeyStore.PasswordProtection(m_password); if (!aAliases.equals(bAliases)) { return false; } for (String alias : aAliases) { // weird, when not using password, cert require null and keys // require the password given to the filestore. KeyStore.PasswordProtection password = keyPass; if (m_store.entryInstanceOf(alias, KeyStore.TrustedCertificateEntry.class)) { password = null; } Entry aEntry = m_store.getEntry(alias, password); Entry bEntry = b.getEntry(alias, password); if (!isEqual(aEntry, bEntry)) { return false; } } return true; } catch (Exception e) { LOG.error("Could not read store", e); return false; } }
From source file:org.obm.push.backend.obm22.mail.EmailCacheStorage.java
@Override public MailChanges getSync(StoreClient imapStore, Integer devId, BackendSession bs, SyncState state, Integer collectionId) throws InterruptedException, SQLException { long time = System.currentTimeMillis(); long ct = System.currentTimeMillis(); Set<Long> memoryCache = loadMailFromDb(bs, devId, collectionId); ct = System.currentTimeMillis() - ct; long writeTime = System.currentTimeMillis(); Set<Long> current = loadMailFromIMAP(bs, imapStore, null); if (!current.equals(memoryCache)) { updateDbCache(bs, devId, collectionId, current); } else if (state.getLastSync() != null && this.lastSyncDate != null && !state.getLastSync().after(this.lastSyncDate) && state.getKey().equals(this.lastSyncKey)) { return this.mailChangesCache; }/*w ww .j a v a 2 s .com*/ writeTime = System.currentTimeMillis() - writeTime; long computeChangesTime = System.currentTimeMillis(); Set<Long> lastUp = loadMailFromIMAP(bs, imapStore, state.getLastSync()); MailChanges sync = computeChanges(memoryCache, current, lastUp); this.mailChangesCache = sync; computeChangesTime = System.currentTimeMillis() - computeChangesTime; time = System.currentTimeMillis() - time; logger.info("[" + bs.getLoginAtDomain() + "]: collectionId [" + collectionId + "] " + (sync.getUpdated().size() + sync.getRemoved().size()) + " changes found. (" + time + "ms (loadCache: " + ct + "ms, updCache: " + writeTime + "ms, computeChanges: " + computeChangesTime + "ms))"); memoryCache = current; this.lastSyncKey = state.getKey(); this.lastSyncDate = state.getLastSync(); return sync; }
From source file:eu.musesproject.windowsclient.contextmonitoring.sensors.ConnectivitySensor.java
private boolean identicalContextEvent(ContextEvent oldEvent, ContextEvent newEvent) { if (oldEvent.getProperties().size() != newEvent.getProperties().size()) { return false; }// ww w. ja va 2 s . co m // compare property values Set<String> oldValues = new HashSet<String>(oldEvent.getProperties().values()); Set<String> newValues = new HashSet<String>(newEvent.getProperties().values()); return oldValues.equals(newValues); }
From source file:de.uni_koblenz.jgralab.utilities.schemacompare.SchemaCompare.java
private void compareHierarchy(GraphElementClass<?, ?> g, GraphElementClass<?, ?> h) { // superclasses Set<String> gsup = getQNameSet(g.getDirectSuperClasses()); Set<String> hsup = getQNameSet(h.getDirectSuperClasses()); if (!gsup.equals(hsup)) { reportDiff(g.getQualifiedName() + " superclasses: " + gsup, h.getQualifiedName() + " superclasses: " + hsup); }/*from ww w . jav a 2s. c om*/ // subclassses Set<String> gsub = getQNameSet(g.getAllSubClasses()); Set<String> hsub = getQNameSet(h.getAllSubClasses()); if (!gsub.equals(hsub)) { reportDiff(g.getQualifiedName() + " subclasses: " + gsub, h.getQualifiedName() + " subclasses: " + hsub); } }
From source file:android.support.v14.preference.MultiSelectListPreference.java
/** * Attempts to persist a set of Strings to the {@link android.content.SharedPreferences}. * <p>//from w w w . java2 s .co m * This will check if this Preference is persistent, get an editor from * the {@link android.preference.PreferenceManager}, put in the strings, and check if we should * commit (and commit if so). * * @param values The values to persist. * @return True if the Preference is persistent. (This is not whether the * value was persisted, since we may not necessarily commit if there * will be a batch commit later.) * @see #getPersistedString * * @hide */ protected boolean persistStringSet(Set<String> values) { if (shouldPersist()) { // Shouldn't store null if (values.equals(getPersistedStringSet(null))) { // It's already there, so the same as persisting return true; } SharedPreferences.Editor editor = getPreferenceManager().getSharedPreferences().edit(); editor.putStringSet(getKey(), values); SharedPreferencesCompat.EditorCompat.getInstance().apply(editor); return true; } return false; }
From source file:org.sonar.server.issue.IssueFieldsSetter.java
public boolean setTags(DefaultIssue issue, Collection<String> tags, IssueChangeContext context) { Set<String> newTags = tags.stream().filter(Objects::nonNull).filter(tag -> !tag.isEmpty()) .map(tag -> RuleTagFormat.validate(tag.toLowerCase(Locale.ENGLISH))) .collect(MoreCollectors.toSet()); Set<String> oldTags = Sets.newHashSet(issue.tags()); if (!oldTags.equals(newTags)) { issue.setFieldChange(context, TAGS, oldTags.isEmpty() ? null : CHANGELOG_TAG_JOINER.join(oldTags), newTags.isEmpty() ? null : CHANGELOG_TAG_JOINER.join(newTags)); issue.setTags(newTags);/*from www . j a va 2 s. c o m*/ issue.setUpdateDate(context.date()); issue.setChanged(true); issue.setSendNotifications(true); return true; } return false; }
From source file:pl.epo.kzd.sync.rt.WomiInRt.java
private boolean differ(Collection<String> col1, Collection<String> col2) { Set<String> set1 = new HashSet<>(normalize(col1)); Set<String> set2 = new HashSet<>(normalize(col2)); boolean differ = !set1.equals(set2); if (differ) { log.debug(String.format("the collections differ for WOMI %d: %s and %s", id, col1, col2)); }/*from ww w.ja v a 2 s. c o m*/ return differ; }
From source file:org.sonar.server.issue.IssueUpdater.java
public boolean setTags(DefaultIssue issue, Collection<String> tags, IssueChangeContext context) { Set<String> newTags = Sets .newHashSet(Collections2.transform(Collections2.filter(tags, new Predicate<String>() { @Override/*from www. ja va2s.com*/ public boolean apply(@Nullable String tag) { return tag != null && !tag.isEmpty(); } }), new Function<String, String>() { @Override public String apply(String tag) { String lowerCaseTag = tag.toLowerCase(Locale.ENGLISH); RuleTagFormat.validate(lowerCaseTag); return lowerCaseTag; } })); Set<String> oldTags = Sets.newHashSet(issue.tags()); if (!oldTags.equals(newTags)) { issue.setFieldChange(context, TAGS, oldTags.isEmpty() ? null : CHANGELOG_TAG_JOINER.join(oldTags), newTags.isEmpty() ? null : CHANGELOG_TAG_JOINER.join(newTags)); issue.setTags(newTags); issue.setUpdateDate(context.date()); issue.setChanged(true); issue.setSendNotifications(true); return true; } return false; }
From source file:de.tudarmstadt.ukp.dkpro.wsd.candidates.SenseClusterer.java
/** * Given two sense IDs, determine whether they are in the same cluster. * * @param sense1/*from w ww .java2 s .com*/ * The first sense ID * @param sense2 * The second sense ID * @return true if sense1 and sense2 are in the same cluster. */ public boolean inSameCluster(String sense1, String sense2) { if (sense1.equals(sense2)) { return true; } Set<String> cluster1 = clusterMap.get(sense1); Set<String> cluster2 = clusterMap.get(sense2); if (cluster1 == null || cluster2 == null) { return false; } return cluster1.equals(cluster2); }
From source file:com.delphix.session.service.ServiceOptions.java
/** * Return true if the options is complete. *///from w ww.java 2 s . c om public boolean isComplete() { Set<ServiceOption<?>> specified = options.keySet(); Set<ServiceOption<?>> supported = ServiceOption.supportedOptions(); return specified.equals(supported); }