List of usage examples for java.lang Object hashCode
@HotSpotIntrinsicCandidate public native int hashCode();
From source file:org.apache.tinkerpop.gremlin.process.traversal.step.util.Parameters.java
public int hashCode() { int result = 1; for (final Map.Entry<Object, List<Object>> entry : this.parameters.entrySet()) { result ^= entry.getKey().hashCode(); for (final Object value : entry.getValue()) { result ^= Integer.rotateLeft(value.hashCode(), entry.getKey().hashCode()); }//from w ww. jav a2 s. c om } return result; }
From source file:ConcurrentReaderHashMap.java
/** * Return hash code for Object x. Since we are using power-of-two * tables, it is worth the effort to improve hashcode via * the same multiplicative scheme as used in IdentityHashMap. *///from w w w .j a va 2s . c om private static int hash(Object x) { int h = x.hashCode(); // Multiply by 127 (quickly, via shifts), and mix in some high // bits to help guard against bunching of codes that are // consecutive or equally spaced. return ((h << 7) - h + (h >>> 9) + (h >>> 17)); }
From source file:Main.java
public static int deepHashCode(Object obj) { Set visited = new HashSet(); LinkedList<Object> stack = new LinkedList<Object>(); stack.addFirst(obj);/*from w ww . ja v a2s .c o m*/ int hash = 0; while (!stack.isEmpty()) { obj = stack.removeFirst(); if (obj == null || visited.contains(obj)) { continue; } visited.add(obj); if (obj.getClass().isArray()) { int len = Array.getLength(obj); for (int i = 0; i < len; i++) { stack.addFirst(Array.get(obj, i)); } continue; } if (obj instanceof Collection) { stack.addAll(0, (Collection) obj); continue; } if (obj instanceof Map) { stack.addAll(0, ((Map) obj).keySet()); stack.addAll(0, ((Map) obj).values()); continue; } if (hasCustomHashCode(obj.getClass())) { hash += obj.hashCode(); continue; } Collection<Field> fields = getDeepDeclaredFields(obj.getClass()); for (Field field : fields) { try { stack.addFirst(field.get(obj)); } catch (Exception ignored) { } } } return hash; }
From source file:org.springframework.nanotrader.account.Account.java
public boolean equals(Object o) { if (o == null) { return false; }//from ww w. j a va2 s . co m if (!(o instanceof Account)) { return false; } return o.hashCode() == hashCode(); }
From source file:IntMap.java
/** * Puts a new value in the property table with the appropriate flags *//*from ww w .j a v a 2s. co m*/ public int get(Object key) { int mask = _mask; int hash = key.hashCode() % mask & mask; Object[] keys = _keys; while (true) { Object mapKey = keys[hash]; if (mapKey == null) return NULL; else if (mapKey == key || mapKey.equals(key)) return _values[hash]; hash = (hash + 1) % mask; } }
From source file:com.vip.saturn.job.console.domain.RegistryCenterConfiguration.java
public int hashCode() { int PRIME = 59; int result = 1; Object $name = getName(); result = result * 59 + ($name == null ? 43 : $name.hashCode()); Object $namespace = getNamespace(); result = result * 59 + ($namespace == null ? 43 : $namespace.hashCode()); Object $sysAdmin = getSysAdmin(); result = result * 59 + ($sysAdmin == null ? 43 : $sysAdmin.hashCode()); Object $techAdmin = getTechAdmin(); result = result * 59 + ($techAdmin == null ? 43 : $techAdmin.hashCode()); Object $degree = getDegree(); return result * 59 + ($degree == null ? 43 : $degree.hashCode()); }
From source file:IntMap.java
/** * Deletes the entry. Returns true if successful. *///from www . ja v a 2s. c o m public int remove(Object key) { int mask = _mask; int hash = key.hashCode() % mask & mask; while (true) { Object mapKey = _keys[hash]; if (mapKey == null) return NULL; else if (mapKey == key) { _keys[hash] = DELETED; _size--; return _values[hash]; } hash = (hash + 1) % mask; } }
From source file:grails.plugin.cache.CustomCacheKeyGenerator.java
public Object generate(Object target, Method method, Object... params) { Class<?> objClass = AopProxyUtils.ultimateTargetClass(target); return new CacheKey(objClass.getName().intern(), method.toString().intern(), target.hashCode(), innerKeyGenerator.generate(target, method, params)); }
From source file:com.farmafene.aurius.impl.DatoRegistroTypeBlob.java
/** * {@inheritDoc}/*from w ww .j a v a 2s . c om*/ * * @see java.lang.Object#equals(java.lang.Object) * @since 1.0.0 */ @Override public boolean equals(Object obj) { boolean iguales = false; if (obj instanceof DatoRegistroTypeBlob) { iguales = this.hashCode() == obj.hashCode(); } return iguales; }
From source file:org.web4thejob.setting.DefaultSetting.java
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; return obj instanceof Setting && hashCode() == obj.hashCode(); }