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

import java.util.Objects;

public class Vec3iImmutable implements Vec3i {
	final int x;
	final int y;
	final int z;
	
	public Vec3iImmutable() {
		x = 0;
		y = 0;
		z = 0;
	}
	
	public Vec3iImmutable(int value) {
		x = value;
		y = value;
		z = value;
	}
	
	public Vec3iImmutable(int x, int y, int z) {
		this.x = x;
		this.y = y;
		this.z = z;
	}
	
	@Override
	public boolean isMutable() { return false; }
	@Override
	public int x() { return x; }
	@Override
	public int y() { return y; }
	@Override
	public int z() { return z; }
	@Override
	public Vec3i x(int x) { return this.x == x ? this : Vec3i.of(x, y, z); }
	@Override
	public Vec3i y(int y) { return this.y == y ? this : Vec3i.of(x, y, z); }
	@Override
	public Vec3i z(int z) { return this.z == z ? this : Vec3i.of(x, y, z); }
	@Override
	public Vec3i copy() { return Vec3i.of(this); }
	@Override
	public Vec3i set(int x, int y, int z) { return this.x == x && this.y == y && this.z == z ? this : Vec3i.of(x, y, z); }
	@Override
	public int hashCode() { return Objects.hash(x, y, z); }
	
	@Override
	public boolean equals(Object obj) {
		if(obj instanceof Vec3i) {
			Vec3i vec = (Vec3i)obj;
			return vec.x() == x && vec.y() == y && vec.z() == z;
		}
		return false;
	}
	
	@Override
	public String toString() { return "Vec3i[x="+x+", y="+y+", z="+z+"]"; }
}
