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

import java.util.Objects;

public class Vec4bImmutable implements Vec4b
{
	final byte x;
	final byte y;
	final byte z;
	final byte w;
	
	public Vec4bImmutable()
	{
		x = 0;
		y = 0;
		z = 0;
		w = 0;
	}
	
	public Vec4bImmutable(byte value)
	{
		x = value;
		y = value;
		z = value;
		w = value;
	}
	
	public Vec4bImmutable(byte x, byte y, byte z, byte w)
	{
		this.x = x;
		this.y = y;
		this.z = z;
		this.w = w;
	}

	@Override
	public boolean isMutable()
	{
		return false;
	}
	
	@Override
	public byte getX()
	{
		return x;
	}
	
	@Override
	public byte getY()
	{
		return y;
	}
	
	@Override
	public byte getZ()
	{
		return z;
	}
	
	@Override
	public byte getW()
	{
		return w;
	}
	
	@Override
	public Vec4b setX(byte x)
	{
		return this.x == x ? this : Vec4b.newVec(x, y, z, w);
	}
	
	@Override
	public Vec4b setY(byte y)
	{
		return this.y == y ? this : Vec4b.newVec(x, y, z, w);
	}
	
	@Override
	public Vec4b setZ(byte z)
	{
		return this.z == z ? this : Vec4b.newVec(x, y, z, w);
	}
	
	@Override
	public Vec4b setW(byte w)
	{
		return this.w == w ? this : Vec4b.newVec(x, y, z, w);
	}
	
	@Override
	public Vec4b copy()
	{
		return Vec4b.newVec(this);
	}
	
	@Override
	public Vec4b set(byte x, byte y, byte z, byte w)
	{
		return this.x == x && this.y == y && this.z == z && this.w == w ? this : Vec4b.newVec(x, y, z, w);
	}
	
	@Override
	public int hashCode()
	{
		return Objects.hash(x, y, z, w);
	}

	@Override
	public boolean equals(Object obj)
	{
		if(obj instanceof Vec4b)
		{
			Vec4b vec = (Vec4b)obj;
			return vec.getX() == x && vec.getY() == y && vec.getZ() == z && vec.getW() == w;
		}
		return false;
	}
	
	@Override
	public String toString()
	{
		return "Vec4b[x="+x+", y="+y+", z="+z+", w="+w+"]";
	}
}
