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

com.taobao.arthas.common.Pair Maven / Gradle / Ivy

There is a newer version: 4.0.3
Show newest version
package com.taobao.arthas.common;

public class Pair {
    private final X x;
    private final Y y;

    public Pair(X x, Y y) {
        this.x = x;
        this.y = y;
    }

    public X getFirst() {
        return x;
    }

    public Y getSecond() {
        return y;
    }

    public static  Pair make(A a, B b) {
        return new Pair(a, b);
    }

    @Override
    public boolean equals(Object o) {
        if (o == this)
            return true;
        if (!(o instanceof Pair))
            return false;

        Pair other = (Pair) o;

        if (x == null) {
            if (other.x != null)
                return false;
        } else {
            if (!x.equals(other.x))
                return false;
        }
        if (y == null) {
            if (other.y != null)
                return false;
        } else {
            if (!y.equals(other.y))
                return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hashCode = 1;
        if (x != null)
            hashCode = x.hashCode();
        if (y != null)
            hashCode = (hashCode * 31) + y.hashCode();
        return hashCode;
    }

    @Override
    public String toString() {
        return "P[" + x + "," + y + "]";
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy