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

org.directwebremoting.util.Pair Maven / Gradle / Ivy

package org.directwebremoting.util;

/**
 * Man this is embarrassing.
 * @author Joe Walker [joe at getahead dot ltd dot uk]
 */
@SuppressWarnings({"ClassEscapesDefinedScope"})
public class Pair
{
    public final A left;

    public final B right;

    public Pair(A left, B right)
    {
        this.left = left;
        this.right = right;
    }

    /* (non-Javadoc)
     * @see java.lang.Object#equals(java.lang.Object)
     */
    @Override
    public boolean equals(Object obj)
    {

        if (obj == null || (!this.getClass().equals(obj.getClass())))
        {
            return false;
        }

        if (obj == this)
        {
            return true;
        }

        @SuppressWarnings("unchecked")
        Pair that = (Pair) obj;

        if (!LocalUtil.equals(this.left, that.left))
        {
            return false;
        }

        if (!LocalUtil.equals(this.right, that.right))
        {
            return false;
        }

        return true;
    }

    /* (non-Javadoc)
     * @see java.lang.Object#hashCode()
     */
    @Override
    public int hashCode()
    {
        int hash = 24;
        hash += (left != null) ? left.hashCode() : 432;
        hash += (right != null) ? right.hashCode() : 635;
        return hash;
    }

    /* (non-Javadoc)
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString()
    {
        return "[" + left + ":" + right + "]";
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy