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

import java.util.Objects;

public class Vec3sImmutable implements Vec3s {
	final short x;
	final short y;
	final short z;
	
	public Vec3sImmutable() {
		x = 0;
		y = 0;
		z = 0;
	}
	
	public Vec3sImmutable(short value) {
		x = value;
		y = value;
		z = value;
	}
	
	public Vec3sImmutable(short x, short y, short z) {
		this.x = x;
		this.y = y;
		this.z = z;
	}
	
	@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 Vec3s x(short x) { return this.x == x ? this : Vec3s.of(x, y, z); }
	@Override
	public Vec3s y(short y) { return this.y == y ? this : Vec3s.of(x, y, z); }
	@Override
	public Vec3s z(short z) { return this.z == z ? this : Vec3s.of(x, y, z); }
	@Override
	public Vec3s copy() { return Vec3s.of(this); }
	@Override
	public Vec3s set(short x, short y, short z) { return this.x == x && this.y == y && this.z == z ? this : Vec3s.of(x, y, z); }
	@Override
	public int hashCode() { return Objects.hash(x, y, z); }
	
	@Override
	public boolean equals(Object obj) {
		if(obj instanceof Vec3s) {
			Vec3s vec = (Vec3s)obj;
			return vec.x() == x && vec.y() == y && vec.z() == z;
		}
		return false;
	}
	
	@Override
	public String toString() { return "Vec3s[x="+x+", y="+y+", z="+z+"]"; }
}
