Example usage for java.util Map equals

List of usage examples for java.util Map equals

Introduction

In this page you can find the example usage for java.util Map equals.

Prototype

boolean equals(Object o);

Source Link

Document

Compares the specified object with this map for equality.

Usage

From source file:org.androidtransfuse.adapter.classes.ASTClassAnnotation.java

@Override
public boolean equals(Object o) {
    if (this == o) {
        return true;
    }/*from   www  . jav a  2s .c o  m*/
    if (!(o instanceof ASTAnnotation)) {
        return false;
    }

    ASTAnnotation that = (ASTAnnotation) o;

    if (!type.equals(that.getASTType())) {
        return false;
    }

    Map<String, Object> thisProperties = new HashMap<String, Object>();
    Map<String, Object> thatProperties = new HashMap<String, Object>();

    for (String property : getPropertyNames()) {
        thisProperties.put(property, this.getProperty(property, Object.class));
        thatProperties.put(property, that.getProperty(property, Object.class));
    }

    return thisProperties.equals(thatProperties);
}

From source file:net.solarnetwork.central.dras.biz.dao.DaoParticipantBiz.java

@Override
@Transactional(readOnly = false, propagation = Propagation.REQUIRED)
public Capability storeParticipantCapability(Long participantId, Capability template) {
    Participant p = participantDao.get(participantId);
    if (p == null) {
        return null;
    }//w  w w . ja va 2 s .c  om
    Capability current = p.getCapability();
    Set<String> ignore = new HashSet<String>();
    ignore.add("id");
    ignore.add("created");
    if (current != null) {
        Map<String, Object> currValues = ClassUtils.getBeanProperties(current, ignore);
        Map<String, Object> newValues = ClassUtils.getBeanProperties(template, ignore);
        if (currValues.equals(newValues)) {
            // nothing has changed, don't create new mapping
            return current;
        }
    }
    Capability entity = (current == null ? new Capability() : current);
    ClassUtils.copyBeanProperties(template, entity, ignore);
    Long capabilityId = capabilityDao.store(entity);
    p.setCapability(capabilityDao.get(capabilityId));
    participantDao.store(p);
    return p.getCapability();
}

From source file:net.solarnetwork.central.dras.biz.dao.DaoParticipantBiz.java

@Override
@Transactional(readOnly = false, propagation = Propagation.REQUIRED)
public Capability storeParticipantGroupCapability(Long participantGroupId, Capability template) {
    ParticipantGroup g = participantGroupDao.get(participantGroupId);
    if (g == null) {
        return null;
    }//www.  j  a  v a  2s.  c o m
    Capability current = g.getCapability();
    Set<String> ignore = new HashSet<String>();
    ignore.add("id");
    ignore.add("created");
    if (current != null) {
        Map<String, Object> currValues = ClassUtils.getBeanProperties(current, ignore);
        Map<String, Object> newValues = ClassUtils.getBeanProperties(template, ignore);
        if (currValues.equals(newValues)) {
            // nothing has changed, don't create new mapping
            return current;
        }
    }
    Capability entity = (current == null ? new Capability() : current);
    ClassUtils.copyBeanProperties(template, entity, ignore);
    Long capabilityId = capabilityDao.store(entity);
    entity.setId(capabilityId);
    g.setCapability(entity);
    participantGroupDao.store(g);
    return g.getCapability();
}

From source file:org.duracloud.mill.dup.DuplicationTaskProcessor.java

/**
 * Determines if source and destination properties are equal.
 *
 * @param sourceProps properties from the source content item
 * @param destProps properties from the destination content item
 * @return true if all properties match/*from  w w w  .  ja  va 2s.  co m*/
 */
protected boolean compareProperties(Map<String, String> sourceProps, Map<String, String> destProps) {
    return sourceProps.equals(destProps);
}

From source file:ch.cyberduck.ui.action.WriteMetadataWorker.java

@Override
public Map<String, String> run() {
    for (Path next : files) {
        final Map<String, String> updated = new HashMap<String, String>(metadata);
        for (Map.Entry<String, String> entry : updated.entrySet()) {
            // Prune metadata from entries which are unique to a single file. For example md5-hash.
            if (StringUtils.isBlank(entry.getValue())) {
                // Reset with previous value
                updated.put(entry.getKey(), next.attributes().getMetadata().get(entry.getKey()));
            }/*from   ww  w. j a  va  2  s .  c o m*/
        }
        if (updated.equals(next.attributes().getMetadata())) {
            if (log.isInfoEnabled()) {
                log.info("Skip writing equal metadata for " + next);
            }
        } else {
            next.writeMetadata(updated);
        }
    }
    return metadata;
}

From source file:org.sonatype.nexus.index.NexusScanningListener.java

private boolean equals(final Document d1, final Document d2) {
    // d1 is never null, check caller
    if (d1 == null && d2 == null) {
        return true;
    }/* w  ww. j a  v  a 2 s  .  c  om*/
    // d2 is never null, check caller
    if (d1 == null || d2 == null) {
        return false;
    }
    final Map<String, String> m1 = toMap(d1);
    final Map<String, String> m2 = toMap(d2);
    m1.remove(MinimalArtifactInfoIndexCreator.FLD_LAST_MODIFIED.getKey());
    m2.remove(MinimalArtifactInfoIndexCreator.FLD_LAST_MODIFIED.getKey());

    final boolean result = m1.equals(m2);
    if (!result) {
        logger.trace("d1={}, d2={}", m1, m2);
    }
    return result;
}

From source file:org.apache.metron.indexing.dao.UpdateIntegrationTest.java

protected void findUpdatedDoc(Map<String, Object> message0, String guid, String sensorType)
        throws InterruptedException, IOException, OriginalNotFoundException {
    for (int t = 0; t < MAX_RETRIES; ++t, Thread.sleep(SLEEP_MS)) {
        Document doc = getDao().getLatest(guid, sensorType);
        if (doc != null && message0.equals(doc.getDocument())) {
            return;
        }/*from   ww w  . j  a  v a 2 s.  co  m*/
        if (t == MAX_RETRIES - 1) {
            MapUtils.debugPrint(System.out, "Expected", message0);
            MapUtils.debugPrint(System.out, "actual", doc.getDocument());
        }
    }
    throw new OriginalNotFoundException("Count not find " + guid + " after " + MAX_RETRIES + " tries");
}

From source file:com.andrew67.ddrfinder.activity.MapViewer.java

@Override
protected void onResume() {
    super.onResume();
    // Clear all markers and reload current view when a preference changed.
    final Map<String, ?> currPrefs = PreferenceManager.getDefaultSharedPreferences(this).getAll();
    if (prevPrefs != null && !currPrefs.equals(prevPrefs)) {
        clearMap();//from  w w  w  .  ja  v  a  2  s  . c o m
        if (isAutoloadEnabled()) {
            updateMap(false);
        }
    }
}

From source file:edu.umich.flowfence.service.KVSSharedPrefs.java

@Override
@SuppressWarnings("unchecked")
public synchronized Map<String, ?> getAll() {
    checkRead();/*from w  w  w  .  j ava2s. co m*/
    TaintSet.Builder tsb = new TaintSet.Builder();
    Map<String, Object> data = new HashMap<>();

    for (Map.Entry<ImmutablePair<String, String>, ?> entry : mPrefs.getAll().entrySet()) {
        ImmutablePair<String, String> typeAndKey = entry.getKey();
        if (DATA.equals(typeAndKey.getLeft())) {
            // If this is a data entry, remember it.
            data.put(typeAndKey.getRight(), entry.getValue());
        } else if (TAINT.equals(typeAndKey.getKey())) {
            // If this is a taint entry, add it to the overall taint label.
            tsb.unionWith((TaintSet) entry.getValue());
        }
    }

    if (mSandbox != null) {
        mSandbox.addTaint(tsb.build());
    }

    return data;
}

From source file:org.elasticsearch.xpack.qa.sql.rest.RestSqlTestCase.java

private void assertResponse(Map<String, Object> expected, Map<String, Object> actual) {
    if (false == expected.equals(actual)) {
        NotEqualMessageBuilder message = new NotEqualMessageBuilder();
        message.compareMaps(actual, expected);
        fail("Response does not match:\n" + message.toString());
    }/*from   w  ww  .  j a  v  a2  s.c o  m*/
}