1 /* 2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package java.lang; 27 28 29 /** 30 * A class implements the {@code Hashable32} interface to indicate that it 31 * provides a method for generating 32-bit hash values for instances. 32 * 33 * @since 1.8 34 */ 35 public interface Hashable32 { 36 37 /** 38 * Return a 32-bit hash code value for this object. 39 * <p> 40 * The general contract of {@code hash32} is: 41 * <ul> 42 * <li>Whenever it is invoked on the same object more than once during 43 * an execution of a Java application, the {@code hash32} method 44 * must consistently return the same integer, provided no information 45 * used in {@code equals} comparisons on the object is modified. 46 * This integer need not remain consistent from one execution of an 47 * application to another execution of the same application. 48 * <li>If two objects are equal according to the {@code equals(Object)} 49 * method, then calling the {@code hash32} method on each of 50 * the two objects must produce the same integer result. 51 * <li>It is <em>not</em> required that if two objects are unequal 52 * according to the {@link java.lang.Object#equals(java.lang.Object)} 53 * method, then calling the {@code hash32} method on each of the 54 * two objects must produce distinct integer results. However, the 55 * programmer should be aware that producing distinct integer results 56 * for unequal objects may improve the performance of hash tables. 57 * </ul> 58 * 59 * @return a hash code value for this object. 60 * @see java.lang.Object#equals(java.lang.Object) 61 */ 62 int hash32(); // default { hashCode() } 63 }