public static int hash(Object key, FieldType fieldType) {
        switch(fieldType) {
        case INT:
            return HashCodes.hashInt(((Integer)key).intValue());
        case LONG:
            long longVal = ((Long)key).longValue();
            return HashCodes.hashInt((int)(longVal ^ (longVal >>> 32)));
        case REFERENCE:
            return HashCodes.hashInt(((Integer)key).intValue());
        case BYTES:
            return HashCodes.hashInt(HashCodes.hashCode((byte[])key));
        case STRING:
            return HashCodes.hashInt(key.hashCode());
        case BOOLEAN:
            return HashCodes.hashInt(((Boolean)key).booleanValue() ? 1231 : 1237);
        case DOUBLE:
            long longBits = Double.doubleToRawLongBits(((Double)key).doubleValue());
            return HashCodes.hashInt((int)(longBits ^ (longBits >>> 32)));
        case FLOAT:
            return HashCodes.hashInt(Float.floatToRawIntBits(((Float)key).floatValue()));
        default:
            throw new IllegalArgumentException("Unknown field type: " + fieldType);
        }
    }
public static int hash(Object key, FieldType fieldType) {
        switch(fieldType) {
        case INT:
            return HashCodes.hashInt(((Integer)key).intValue());
        case LONG:
            long longVal = ((Long)key).longValue();
            return HashCodes.hashInt((int)(longVal ^ (longVal >>> 32)));
        case REFERENCE:
            return HashCodes.hashInt(((Integer)key).intValue());
        case BYTES:
            return HashCodes.hashInt(HashCodes.hashCode((byte[])key));
        case STRING:
            return HashCodes.hashInt(key.hashCode());
        case BOOLEAN:
            return HashCodes.hashInt(((Boolean)key).booleanValue() ? 1231 : 1237);
        case DOUBLE:
            long longBits = Double.doubleToRawLongBits(((Double)key).doubleValue());
            return HashCodes.hashInt((int)(longBits ^ (longBits >>> 32)));
        case FLOAT:
            return HashCodes.hashInt(Float.floatToRawIntBits(((Float)key).floatValue()));
        default:
            throw new IllegalArgumentException("Unknown field type: " + fieldType);
        }
    }
public static int hash ( Object key , FieldType fieldType ) { switch ( fieldType ) { case INT : return HashCodes . hashInt ( ( ( Integer ) key ) . intValue ( ) ) ; case LONG : long longVal = ( ( Long ) key ) . longValue ( ) ; return HashCodes . hashInt ( ( int ) ( longVal ^ ( longVal >>> 32 ) ) ) ; case REFERENCE : return HashCodes . hashInt ( ( ( Integer ) key ) . intValue ( ) ) ; case BYTES : return HashCodes . hashInt ( HashCodes . hashCode ( ( byte [ ] ) key ) ) ; case STRING : return HashCodes . hashInt ( key . hashCode ( ) ) ; case BOOLEAN : return HashCodes . hashInt ( ( ( Boolean ) key ) . booleanValue ( ) ? 1231 : 1237 ) ; case DOUBLE : long longBits = Double . doubleToRawLongBits ( ( ( Double ) key ) . doubleValue ( ) ) ; return HashCodes . hashInt ( ( int ) ( longBits ^ ( longBits >>> 32 ) ) ) ; case FLOAT : return HashCodes . hashInt ( Float . floatToRawIntBits ( ( ( Float ) key ) . floatValue ( ) ) ) ; default : throw new IllegalArgumentException ( "Unknown field type: " + fieldType ) ; } }
Hash a single key field

@param key the key
@param fieldType the FieldType of the key.
@return the hash code
Hash a single key field