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

import java.util.Objects;

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