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

import java.util.Objects;

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