List of usage examples for java.lang Object hashCode
@HotSpotIntrinsicCandidate public native int hashCode();
From source file:ResourceBundleSupport.java
/** * Returns a hash code for an object, or zero if the object is * <code>null</code>.//from w ww. ja v a2 s. com * * @param object the object (<code>null</code> permitted). * @return The object's hash code (or zero if the object is * <code>null</code>). */ public static int hashCode(final Object object) { int result = 0; if (object != null) { result = object.hashCode(); } return result; }
From source file:ch.cyberduck.core.DefaultPathPredicate.java
/** * Comparing the hashcode./*w w w.j av a 2 s .c o m*/ * * @see #hashCode() */ @Override public boolean equals(Object other) { if (null == other) { return false; } if (other instanceof CacheReference) { return this.hashCode() == other.hashCode(); } return false; }
From source file:org.openmrs.module.reporting.report.service.db.MappedDefinitionType.java
/** * @see UserType#hashCode(Object)/* w ww . jav a 2s .c o m*/ */ public int hashCode(Object x) throws HibernateException { return x.hashCode(); }
From source file:com.cloud2bubble.services.RuleEngine.java
/** * Inserts any object into the Rule Engine. * //w w w.j a v a 2 s.c o m * @param o a fact */ public void insertInSession(Object o) { FactHandle fh = ksession.insert(o); facts.put(o.hashCode(), fh); }
From source file:nl.surfnet.coin.shared.cache.MethodNameAwareCacheKeyGenerator.java
@Override public Object generate(Object target, Method method, Object... params) { Object hash = super.generate(target, method, params); return new StringBuilder(hash != null ? hash.toString() : "31").append(method.getName()) .append(target.hashCode()).toString(); }
From source file:org.web4thejob.message.DefaultMessage.java
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; return obj instanceof Message && hashCode() == obj.hashCode(); }
From source file:com.vmware.appfactory.common.base.AbstractApiController.java
/** * Sets an e-tag on the request calculated from the given DAO. * * If the request contains the same e-tag, this means the resource * has not been modified since the last request, and the browser cache * already contains the whole response./*from w w w .ja va 2 s . co m*/ * * In this case, we'll set the HTTP headers to indicate that the * response has not been modified, and return true. * * @param request - web request, used to get client's etag (if any) * @param response - web response, used to set 304 response if necessary * @param objCollection - A collection of objects. If set, the e-tag is computed based on the hashCode * for each of the objects. * @param daoList - one or more DAOs to query. The e-tag is computed using the current state of each * of these tables, such that if any changes the computed e-tag should change. * @return * true - if the client already has a cached version of the resource. * When this is returned, this method has written an HTTP response, * and the caller should simply return immediately. * * false - if the E-Tag header has been set and the caller should * proceed to generate and write a normal response. * * @throws IOException * if the 304 response could not be written */ public boolean checkModified(@Nonnull HttpServletRequest request, @Nonnull HttpServletResponse response, Collection<? extends Object> objCollection, @Nonnull AfDao... daoList) throws IOException { String charSequence = "optimus-prime"; Hasher hasher = hashFunction.newHasher().putString(charSequence); for (AfDao dao : daoList) { long lastModified = dao.lastModified(); long size = dao.countAll(); hasher.putLong(lastModified).putLong(size); } // If the objects are not present, put a 0 value indicating 0 sized objects. if (CollectionUtils.isNotEmpty(objCollection)) { for (Object o : objCollection) { if (o != null) { hasher.putInt(o.hashCode()); } else { // Indicating that there was an object but null. hasher.putInt(0); } } } String newToken = hasher.hash().toString(); String oldToken = applyETagCache(request, response, newToken, false); return newToken.equals(oldToken); }
From source file:com.espertech.esper.core.context.mgr.ContextControllerHashedGetterHashMultiple.java
public Object get(EventBean eventBean) throws PropertyAccessException { EventBean[] events = new EventBean[] { eventBean }; int hashCode = 0; for (int i = 0; i < evaluators.length; i++) { Object result = evaluators[i].evaluate(events, true, null); if (result == null) { continue; }//w w w . ja v a 2 s .co m if (hashCode == 0) { hashCode = result.hashCode(); } else { hashCode = 31 * hashCode + result.hashCode(); } } if (hashCode >= 0) { return hashCode % granularity; } return -hashCode % granularity; }
From source file:com.oodlemud.appengine.counter.Counter.java
@java.lang.Override @java.lang.SuppressWarnings("all") public int hashCode() { final int PRIME = 31; int result = 1; final java.lang.Object $counterName = this.getCounterName(); result = result * PRIME + ($counterName == null ? 0 : $counterName.hashCode()); final java.lang.Object $counterStatus = this.getCounterStatus(); result = result * PRIME + ($counterStatus == null ? 0 : $counterStatus.hashCode()); final long $count = this.getCount(); result = result * PRIME + (int) ($count >>> 32 ^ $count); return result; }
From source file:org.codehaus.groovy.grails.orm.hibernate.cfg.IdentityEnumType.java
public int hashCode(Object o) throws HibernateException { return o.hashCode(); }