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

org.bitcoinj.utils.Pair Maven / Gradle / Ivy

There is a newer version: 21.0.0
Show newest version
package org.bitcoinj.utils;

import java.util.Comparator;

/**
 * Created by Eric on 2/24/2016.
 */
public class Pair {
    private First first;
    private Second second;

    public Pair(First first, Second second) {
        this.first = first;
        this.second = second;
    }

    public void setFirst(First first) {
        this.first = first;
    }

    public void setSecond(Second second) {
        this.second = second;
    }

    public First getFirst() {
        return first;
    }

    public Second getSecond() {
        return second;
    }

    public void set(First first, Second second) {
        setFirst(first);
        setSecond(second);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Pair pair = (Pair) o;

        if (first != null ? !first.equals(pair.first) : pair.first != null) return false;
        if (second != null ? !second.equals(pair.second) : pair.second != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = first != null ? first.hashCode() : 0;
        result = 31 * result + (second != null ? second.hashCode() : 0);
        return result;
    }

    @Override
    public String toString() {
        return "["+first.toString()+", "+second.toString()+"]";
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy