SimpleJavaEngine/src/main/java/speiger/src/coreengine/math/vector/bytes/Vec2bMutable.java

95 lines
1.1 KiB
Java

package speiger.src.coreengine.math.vector.bytes;
import java.util.Objects;
public class Vec2bMutable implements Vec2b
{
byte x;
byte y;
public Vec2bMutable()
{
}
public Vec2bMutable(byte value)
{
x = value;
y = value;
}
public Vec2bMutable(byte x, byte y)
{
this.x = x;
this.y = y;
}
@Override
public boolean isMutable()
{
return true;
}
@Override
public byte getX()
{
return x;
}
@Override
public byte getY()
{
return y;
}
@Override
public Vec2b setX(byte x)
{
this.x = x;
return this;
}
@Override
public Vec2b setY(byte y)
{
this.y = y;
return this;
}
@Override
public Vec2b copy()
{
return Vec2b.mutable(this);
}
@Override
public Vec2b set(byte x, byte y)
{
this.x = x;
this.y = y;
return this;
}
@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.getX() == x && vec.getY() == y;
}
return false;
}
@Override
public String toString()
{
return "Vec2b[x="+x+", y="+y+"]";
}
}