Example usage for java.lang Object hashCode

List of usage examples for java.lang Object hashCode

Introduction

In this page you can find the example usage for java.lang Object hashCode.

Prototype

@HotSpotIntrinsicCandidate
public native int hashCode();

Source Link

Document

Returns a hash code value for the object.

Usage

From source file:org.eclipse.smarthome.config.core.Configuration.java

@Override
public boolean equals(Object obj) {
    if (this == obj) {
        return true;
    }/*from  w  w  w .j a v  a  2 s  . co m*/
    if (!(obj instanceof Configuration)) {
        return false;
    }
    return this.hashCode() == obj.hashCode();
}

From source file:org.elasticsoftware.elasticactors.rabbitmq.cpt.RabbitMQMessagingService.java

private int getBucket(Object key) {
    return Math.abs(key.hashCode()) % queueExecutor.getThreadCount();
}

From source file:HashSet.java

/**
 * Return the hashCode for an item./*from   w w  w. java 2 s  .c o m*/
 */
protected int itemHashCode(Object o) {
    return (o == null) ? 0 : o.hashCode();
}

From source file:ObjectIntMap.java

public boolean contains(final Object key) {

    // index into the corresponding hash bucket:
    final Entry[] buckets = m_buckets;
    final int keyHash = key.hashCode();
    final int bucketIndex = (keyHash & 0x7FFFFFFF) % buckets.length;

    // traverse the singly-linked list of entries in the bucket:
    for (Entry entry = buckets[bucketIndex]; entry != null; entry = entry.m_next) {
        if ((keyHash == entry.m_key.hashCode()) || entry.m_key.equals(key))
            return true;
    }//from   w  w  w.j  a v a  2  s .  co  m

    return false;
}

From source file:org.web4thejob.command.AbstractCommand.java

@Override
public boolean equals(Object obj) {
    if (this == obj)
        return true;
    if (obj == null)
        return false;
    return obj instanceof Command && hashCode() == obj.hashCode();

}

From source file:org.projectforge.framework.xstream.XmlObjectWriter.java

private Element getRegisteredElement(final Object obj) {
    return writtenObjects.get(obj.getClass().getName() + ":" + obj.hashCode());
}

From source file:com.yosanai.java.swing.editor.ObjectEditorTableModel.java

protected void addRows(Object wrappedObject, String prefix, Set<Integer> visited) {
    if (null == visited) {
        visited = new HashSet<Integer>();
    }/*w ww  .  j a v  a 2s. com*/
    if (null != wrappedObject && !visited.contains(wrappedObject.hashCode())) {
        visited.add(wrappedObject.hashCode());
        BeanWrapper beanWrapper = PropertyAccessorFactory.forBeanPropertyAccess(wrappedObj);
        beanWrapper.setExtractOldValueForEditor(true);
        if (null != dateAndTimePropertyEditor) {
            beanWrapper.registerCustomEditor(Timestamp.class, dateAndTimePropertyEditor);
            beanWrapper.registerCustomEditor(Date.class, dateAndTimePropertyEditor);
        }
        PropertyDescriptor[] propDescs = beanWrapper.getPropertyDescriptors();
        for (PropertyDescriptor propertyDescriptor : propDescs) {
            addRows(beanWrapper, propertyDescriptor, prefix, visited);
        }
    }
}

From source file:org.apache.wsrp4j.persistence.xml.driver.PersistentHandlerImpl.java

/**
 * Delete the related XML persistent file of the input
 * persistentDataObject information./*  ww  w .  j av a2s.  c  o  m*/
 *
 * @param persistentDataObject
 */
public void delete(PersistentDataObject persistentDataObject) {

    String MN = "delete";

    if (log.isDebugEnabled()) {
        log.debug(Utility.strEnter(MN));
    }

    Object o = persistentDataObject.getLastElement();
    int hashCode = o.hashCode();
    String code = new Integer(hashCode).toString();
    String filename = (String) _filenameMap.get(code);
    _filenameMap.remove(code);

    File file = new File(filename);
    if (file.exists()) {
        file.delete();
        if (log.isDebugEnabled()) {
            log.debug("Persistent file: " + filename + " deleted.");
        }
    } else {
        if (log.isDebugEnabled()) {
            log.debug("Trying to delete persistent file: " + filename + ". Not found!");
        }
    }

    if (log.isDebugEnabled()) {
        log.debug(Utility.strExit(MN));
    }

}

From source file:org.projectforge.framework.xstream.XmlObjectWriter.java

private boolean isRegistered(final Object obj) {
    return writtenObjects.containsKey(obj.getClass().getName() + ":" + obj.hashCode());
}

From source file:org.apache.usergrid.chop.stack.CoordinatedStack.java

@Override
public boolean equals(final Object obj) {
    if (this == obj) {
        return true;
    }/*w  ww.jav  a2 s  . c  om*/
    if (obj == null) {
        return false;
    }
    if (!(obj instanceof CoordinatedStack)) {
        return false;
    }
    return obj.hashCode() == this.hashCode();
}