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

import java.util.Objects;

public class Vec4fImmutable implements Vec4f {
	final float x;
	final float y;
	final float z;
	final float w;
	
	public Vec4fImmutable() {
		x = 0;
		y = 0;
		z = 0;
		w = 0;
	}
	
	public Vec4fImmutable(float value) {
		x = value;
		y = value;
		z = value;
		w = value;
	}
	
	public Vec4fImmutable(float x, float y, float z, float w) {
		this.x = x;
		this.y = y;
		this.z = z;
		this.w = w;
	}
	
	@Override
	public boolean isMutable() { return false; }
	@Override
	public float x() { return x; }
	@Override
	public float y() { return y; }
	@Override
	public float z() { return z; }
	@Override
	public float w() { return w; }
	@Override
	public Vec4f x(float x) { return this.x == x ? this : Vec4f.of(x, y, z, w); }
	@Override
	public Vec4f y(float y) { return this.y == y ? this : Vec4f.of(x, y, z, w); }
	@Override
	public Vec4f z(float z) { return this.z == z ? this : Vec4f.of(x, y, z, w); }
	@Override
	public Vec4f w(float w) { return this.w == w ? this : Vec4f.of(x, y, z, w); }
	@Override
	public Vec4f copy() { return Vec4f.of(this); }
	@Override
	public Vec4f set(float x, float y, float z, float w) { return this.x == x && this.y == y && this.z == z && this.w == w ? this : Vec4f.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 Vec4f) {
			Vec4f vec = (Vec4f)obj;
			return vec.x() == x && vec.y() == y && vec.z() == z && vec.w() == w;
		}
		return false;
	}
	
	@Override
	public String toString() { return "Vec4f[x="+x+", y="+y+", z="+z+", w="+w+"]"; }
}
