All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.oracle.coherence.common.base.IdentityHasher Maven / Gradle / Ivy

There is a newer version: 24.03
Show newest version
/*
 * Copyright (c) 2000, 2020, Oracle and/or its affiliates.
 *
 * Licensed under the Universal Permissive License v 1.0 as shown at
 * http://oss.oracle.com/licenses/upl.
 */
package com.oracle.coherence.common.base;


/**
 * IdentityHasher provides a Hasher implementation based upon an object's
 * {@link System#identityHashCode(Object) identity hashCode} and reference
 * equality.
 *
 * @param   the value type
 *
 * @author mf  2011.01.07
 */
public class IdentityHasher
        implements Hasher
    {
    /**
     * {@inheritDoc}
     */
    @Override
    public int hashCode(V o)
        {
        return System.identityHashCode(o);
        }

    /**
     * {@inheritDoc}
     */
    @Override
    public boolean equals(V va, V vb)
        {
        return va == vb;
        }


    // ----- constants ------------------------------------------------------

    /**
     * A singleton instance of the IdentityHasher.
     */
    public static final IdentityHasher INSTANCE = new IdentityHasher();
    }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy