package com.bunjlabs.jed2d.utils;

import java.util.Objects;

public final class Vector3<T> {

    public final T x, y, z;

    protected Vector3(Vector3<T> v) {
        this.x = v.x;
        this.y = v.y;
        this.z = v.z;
    }

    protected Vector3(T v) {
        this.x = v;
        this.y = v;
        this.z = v;
    }

    protected Vector3(T x, T y, T z) {
        this.x = x;
        this.y = y;
        this.z = z;
    }

    protected Vector3() {
        this.x = this.y = this.z = null;
    }

    public static Vector3 create() {
        return new Vector3();
    }

    public static <T> Vector3<T> create(T x) {
        return new Vector3<>(x);
    }

    public static <T> Vector3<T> create(T x, T y, T z) {
        return new Vector3<>(x, y, z);
    }

    public static <T> Vector3<T> create(Vector3<T> v) {
        return new Vector3<>(v);
    }

    @Override
    public String toString() {
        return "Vector3{" + "x=" + x + ", y=" + y + ", z=" + z + '}';
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 53 * hash + Objects.hashCode(this.x);
        hash = 53 * hash + Objects.hashCode(this.y);
        hash = 53 * hash + Objects.hashCode(this.z);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Vector3<?> other = (Vector3<?>) obj;
        if (!Objects.equals(this.x, other.x)) {
            return false;
        }
        if (!Objects.equals(this.y, other.y)) {
            return false;
        }
        if (!Objects.equals(this.z, other.z)) {
            return false;
        }
        return true;
    }

}
