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

import java.util.Objects;

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