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

import java.util.Objects;

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