Tuple3

public class Tuple3<T0, T1, T2> {
    private static final long serialVersionUID = 1L;
    public T0 f0;
    public T1 f1;
    public T2 f2;

    public Tuple3() {
    }

    public Tuple3(T0 f0, T1 f1, T2 f2) {
        this.f0 = f0;
        this.f1 = f1;
        this.f2 = f2;
    }

    public int getArity() {
        return 3;
    }

    public <T> T getField(int pos) {
        switch(pos) {
            case 0:
                return (T)this.f0;
            case 1:
                return (T)this.f1;
            case 2:
                return (T)this.f2;
            default:
                throw new IndexOutOfBoundsException(String.valueOf(pos));
        }
    }

    public <T> void setField(T value, int pos) {
        switch(pos) {
            case 0:
                this.f0 = (T0)value;
                break;
            case 1:
                this.f1 = (T1)value;
                break;
            case 2:
                this.f2 = (T2)value;
                break;
            default:
                throw new IndexOutOfBoundsException(String.valueOf(pos));
        }

    }

    public void setFields(T0 f0, T1 f1, T2 f2) {
        this.f0 = f0;
        this.f1 = f1;
        this.f2 = f2;
    }

    @Override
    public String toString() {
        return "(" + this.f0+"," + this.f1+ "," + this.f2+ ")";
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        } else if (!(o instanceof Tuple3)) {
            return false;
        } else {
            Tuple3 tuple;
            label44: {
                tuple = (Tuple3)o;
                if (this.f0 != null) {
                    if (this.f0.equals(tuple.f0)) {
                        break label44;
                    }
                } else if (tuple.f0 == null) {
                    break label44;
                }

                return false;
            }

            if (this.f1 != null) {
                if (!this.f1.equals(tuple.f1)) {
                    return false;
                }
            } else if (tuple.f1 != null) {
                return false;
            }

            if (this.f2 != null) {
                if (!this.f2.equals(tuple.f2)) {
                    return false;
                }
            } else if (tuple.f2 != null) {
                return false;
            }

            return true;
        }
    }

    @Override
    public int hashCode() {
        int result = this.f0 != null ? this.f0.hashCode() : 0;
        result = 31 * result + (this.f1 != null ? this.f1.hashCode() : 0);
        result = 31 * result + (this.f2 != null ? this.f2.hashCode() : 0);
        return result;
    }

    public Tuple3<T0, T1, T2> copy() {
        return new Tuple3(this.f0, this.f1, this.f2);
    }

    public static <T0, T1, T2> Tuple3<T0, T1, T2> of(T0 f0, T1 f1, T2 f2) {
        return new Tuple3(f0, f1, f2);
    }
}
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值