List of usage examples for java.lang Object hashCode
@HotSpotIntrinsicCandidate public native int hashCode();
From source file:net.sourceforge.cobertura.metrics.model.location.SourceLocation.java
/** * {@inheritDoc}//from w ww . j a va 2s .c om */ @Override public boolean equals(final Object obj) { // Check sanity if (obj == null) { return false; } // All done. return (obj instanceof SourceLocation) && (hashCode() == obj.hashCode()); }
From source file:org.largecollections.CacheSetWithUnqHashCode.java
public boolean remove(Object e) { boolean contains = this.contains(e); if (contains) { size--;/*from w w w.ja v a2s .c o m*/ db.delete(Integer.toString(e.hashCode()).getBytes()); } return contains; }
From source file:org.apache.wsrp4j.persistence.xml.driver.PersistentHandlerImpl.java
/** * Store a single XML file, contained in the persistentDataObject to * the persistent file store via the marshalFile method of the input * object. The filename of the object is collected with it's hashcode * internally./* w w w . j av a 2 s. c o m*/ * * @param persistentDataObject * * @throws WSRPException */ public void store(PersistentDataObject persistentDataObject) throws WSRPException { String MN = "store"; if (log.isDebugEnabled()) { log.debug(Utility.strEnter(MN)); } Mapping mapping = null; Marshaller marshaller = null; FileWriter fileWriter = null; String filename = null; try { PersistentInformationXML persistentInformation = (PersistentInformationXML) persistentDataObject .getPersistentInformation(); Object o = persistentDataObject.getLastElement(); int hashCode = o.hashCode(); String code = new Integer(hashCode).toString(); filename = (String) _filenameMap.get(code); if (filename == null) { persistentInformation.updateFileName(code); filename = persistentInformation.getFilename(); _filenameMap.put(code, filename); } File file = new File(filename); if (log.isDebugEnabled()) { log.debug("Filename for store: " + filename + " with code: " + code); } fileWriter = new FileWriter(file); if (persistentInformation.getMappingFileName() != null) { mapping = new Mapping(); mapping.loadMapping(persistentInformation.getMappingFileName()); marshaller = new Marshaller(fileWriter); marshaller.setMapping(mapping); } ((PersistentDataObjectXML) persistentDataObject).marshalFile(fileWriter, marshaller); fileWriter.close(); } catch (Exception e) { // could not store object to persistent file WSRPXHelper.throwX(log, ErrorCodes.STORE_OBJECT_ERROR, e); } if (log.isDebugEnabled()) { log.debug(Utility.strExit(MN)); } }
From source file:org.springjutsu.validation.ValidationEvaluationContext.java
/** * @param bean The bean to check for repeated validation * @return true if the given bean has already been validated. *///from w w w .j av a 2 s . c om protected boolean previouslyValidated(Object bean) { return checkedModelHashes.peek().contains(bean.hashCode()); }
From source file:CompactHashSet.java
/** * Returns <tt>true</tt> if this set contains the specified element. * /*from www . jav a 2s .c o m*/ * @param o * element whose presence in this set is to be tested. * @return <tt>true</tt> if this set contains the specified element. */ public boolean contains(Object o) { if (o == null) o = nullObject; int hash = o.hashCode(); int index = (hash & 0x7FFFFFFF) % objects.length; int offset = 1; // search for the object (continue while !null and !this object) while (objects[index] != null && !(objects[index].hashCode() == hash && objects[index].equals(o))) { index = ((index + offset) & 0x7FFFFFFF) % objects.length; offset = offset * 2 + 1; if (offset == -1) offset = 2; } return objects[index] != null; }
From source file:org.apache.wsrp4j.persistence.xml.driver.PersistentHandlerImpl.java
/** * Restores a single XML file into the persistentDataObject. The filename * used is the filename stored in the PersistentFileInformation, contained * in the PersistentDataObject.//from w w w . j a v a 2 s. co m * * @param persistentDataObject * @return PersistentDataObjct * * @throws WSRPException */ public PersistentDataObject restore(PersistentDataObject persistentDataObject) throws WSRPException { String MN = "restore"; if (log.isDebugEnabled()) { log.debug(Utility.strEnter(MN)); } Mapping mapping = null; Unmarshaller unmarshaller = null; try { PersistentInformationXML persistentInformation = (PersistentInformationXML) persistentDataObject .getPersistentInformation(); if (persistentInformation.getMappingFileName() != null) { mapping = new Mapping(); mapping.loadMapping(persistentInformation.getMappingFileName()); unmarshaller = new Unmarshaller(mapping); } File file = new File(persistentInformation.getFilename()); if (file.isFile()) { FileReader fileReader = new FileReader(file); try { ((PersistentDataObjectXML) persistentDataObject).unMarshalFile(fileReader, unmarshaller); fileReader.close(); Object o = persistentDataObject.getLastElement(); int hashCode = o.hashCode(); String code = new Integer(hashCode).toString(); _filenameMap.put(code, file.getAbsolutePath()); if (log.isDebugEnabled()) { log.debug("File: " + file.getAbsolutePath() + " added with hashCode = " + code); } } catch (Exception e) { // could not restore a single file from persistent store WSRPXHelper.throwX(log, ErrorCodes.RESTORE_OBJECT_ERROR, e); } } } catch (Exception e) { // castor persistent failure WSRPXHelper.throwX(log, ErrorCodes.RESTORE_OBJECT_ERROR, e); } if (log.isDebugEnabled()) { log.debug(Utility.strExit(MN)); } return persistentDataObject; }
From source file:nl.nn.adapterframework.util.StringTagger.java
/** * Returns whether two objects are the same * @param ob the key of the value to retrieve *///w ww. j ava 2 s. c o m public boolean equals(Object ob) { return (ob instanceof Map) && (ob.hashCode() == this.hashCode()); }
From source file:org.lexevs.cache.AbstractMethodCachingBean.java
protected String getArgumentKey(Object argument) { StringBuffer sb = new StringBuffer(); if (argument == null) { sb.append(NULL_VALUE_KEY);/*w w w . j av a 2s .c o m*/ } else { sb.append(argument.hashCode()); } return sb.toString(); }
From source file:org.malaguna.cmdit.service.reflection.ReflectionUtils.java
public boolean compareAndUpdateAttribute(Object oldObj, Object newObj, String atributo, boolean update, StringBuffer msgBuffer, String msgContext) { boolean result = false; if (oldObj != null && newObj != null) { oldObj = hpu.unproxy(oldObj);/*from w w w.ja v a 2 s . c om*/ newObj = hpu.unproxy(newObj); if (!isHibernateProxy(oldObj) && !isHibernateProxy(newObj)) { PropertyDescriptor desc = null; try { String firstAttribute = null; String restAttribute = null; int pos = atributo.indexOf("."); if (pos >= 0) { firstAttribute = atributo.substring(0, pos); restAttribute = atributo.substring(pos + 1); } else { firstAttribute = atributo; } desc = PropertyUtils.getPropertyDescriptor(oldObj, firstAttribute); if (desc != null) { Object oldValue = hpu.unproxy(desc.getReadMethod().invoke(oldObj)); Object newValue = hpu.unproxy(desc.getReadMethod().invoke(newObj)); if (restAttribute == null && !isHibernateProxy(oldValue) && !isHibernateProxy(newValue)) { String auxChangeMsg = null; result = (oldValue != null) ? compareObjects(desc, oldValue, newValue) : (newValue == null); if (!result) { if (msgBuffer != null) { auxChangeMsg = buildChangeMessage(desc, firstAttribute, oldValue, newValue, msgContext); } if (update) { updateOldValue(oldObj, desc, oldValue, newValue); } } if (msgBuffer != null) msgBuffer.append(getAppendMsg(auxChangeMsg, msgBuffer)); } if (restAttribute != null) { if (Collection.class.isAssignableFrom(desc.getPropertyType())) { Collection<?> oldSetAux = (Collection<?>) oldValue; Collection<?> newSetAux = (Collection<?>) newValue; if (oldValue != null && newValue != null) { Collection<?> intersection = CollectionUtils.intersection(oldSetAux, newSetAux); for (Object obj : intersection) { RUPredicate rup = new RUPredicate(obj.hashCode()); Object oldElement = CollectionUtils.find(oldSetAux, rup); Object newElement = CollectionUtils.find(newSetAux, rup); String context = (msgContext != null) ? msgContext + firstAttribute : firstAttribute; context += "([" + oldElement.toString() + "])."; compareAndUpdateAttribute(oldElement, newElement, restAttribute, update, msgBuffer, context); } } } else { compareAndUpdateAttribute(oldValue, newValue, restAttribute, update, msgBuffer); } } } } catch (NoSuchMethodException e) { String error = "Error in compareAndUpdateAttribute, class type [%s] has no property [%s]"; throw new RuntimeException(String.format(error, oldObj.getClass(), atributo), e); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InvocationTargetException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } return result; }
From source file:com.alibaba.citrus.util.internal.apache.lang.HashCodeBuilderTests.java
public void testObject() { Object obj = null; assertEquals(17 * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode()); obj = new Object(); assertEquals(17 * 37 + obj.hashCode(), new HashCodeBuilder(17, 37).append(obj).toHashCode()); }