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

import java.util.Objects;

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