package speiger.src.coreengine.math.vector.doubles;

import java.util.Objects;

public class Vec4dMutable implements Vec4d {
	double x;
	double y;
	double z;
	double w;
	
	public Vec4dMutable() {}
	
	public Vec4dMutable(double value) {
		x = value;
		y = value;
		z = value;
		w = value;
	}
	
	public Vec4dMutable(double x, double y, double z, double w) {
		this.x = x;
		this.y = y;
		this.z = z;
		this.w = w;
	}
	
	@Override
	public boolean isMutable() { return true; }
	@Override
	public double x() { return x; }
	@Override
	public double y() { return y; }
	@Override
	public double z() { return z; }
	@Override
	public double w() { return w; }
	
	@Override
	public Vec4d x(double x) {
		this.x = x;
		return this;
	}
	
	@Override
	public Vec4d y(double y) {
		this.y = y;
		return this;
	}
	
	@Override
	public Vec4d z(double z) {
		this.z = z;
		return this;
	}
	
	@Override
	public Vec4d w(double w) {
		this.w = w;
		return this;
	}
	
	@Override
	public Vec4d copy() { return Vec4d.mutable(this); }
	
	@Override
	public Vec4d set(double x, double y, double z, double w) {
		this.x = x;
		this.y = y;
		this.z = z;
		this.w = w;
		return this;
	}
	
	@Override
	public int hashCode() { return Objects.hash(x, y, z, w); }
	
	@Override
	public boolean equals(Object obj) {
		if(obj instanceof Vec4d) {
			Vec4d vec = (Vec4d)obj;
			return vec.x() == x && vec.y() == y && vec.z() == z && vec.w() == w;
		}
		return false;
	}
	
	@Override
	public String toString() { return "Vec4d[x="+x+", y="+y+", z="+z+", w="+w+"]"; }
}