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

import java.util.Objects;

public class Vec4dImmutable implements Vec4d {
	final double x;
	final double y;
	final double z;
	final double w;
	
	public Vec4dImmutable() {
		x = 0;
		y = 0;
		z = 0;
		w = 0;
	}
	
	public Vec4dImmutable(double value) {
		x = value;
		y = value;
		z = value;
		w = value;
	}
	
	public Vec4dImmutable(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 false; }
	@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) { return this.x == x ? this : Vec4d.of(x, y, z, w); }
	@Override
	public Vec4d y(double y) { return this.y == y ? this : Vec4d.of(x, y, z, w); }
	@Override
	public Vec4d z(double z) { return this.z == z ? this : Vec4d.of(x, y, z, w); }
	@Override
	public Vec4d w(double w) { return this.w == w ? this : Vec4d.of(x, y, z, w); }
	@Override
	public Vec4d copy() { return Vec4d.of(this); }
	
	@Override
	public Vec4d set(double x, double y, double z, double w) {
		return this.x == x && this.y == y && this.z == z && this.w == w ? this : Vec4d.of(x, y, z, w);
	}
	
	@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+"]"; }
}
