package cz.senslog.analytics.utils;

import java.util.Objects;

public final class Tuple<A, B> {

    private final A item1;
    private final B item2;

    private Tuple(A item1, B item2) {
        this.item1 = item1;
        this.item2 = item2;
    }

    public static <A, B> Tuple<A,B> of(A item1, B item2) {
        return new Tuple<>(item1, item2);
    }

    public A getItem1() {
        return item1;
    }

    public B getItem2() {
        return item2;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Tuple<?, ?> tuple = (Tuple<?, ?>) o;
        return Objects.equals(item1, tuple.item1) && Objects.equals(item2, tuple.item2);
    }

    @Override
    public int hashCode() {
        return Objects.hash(item1, item2);
    }
}