60 lines
1.4 KiB
Java
60 lines
1.4 KiB
Java
package speiger.src.coreengine.math.vector.bytes;
|
|
|
|
import java.util.Objects;
|
|
|
|
public class Vec3bImmutable implements Vec3b {
|
|
final byte x;
|
|
final byte y;
|
|
final byte z;
|
|
|
|
public Vec3bImmutable() {
|
|
x = 0;
|
|
y = 0;
|
|
z = 0;
|
|
}
|
|
|
|
public Vec3bImmutable(byte value) {
|
|
x = value;
|
|
y = value;
|
|
z = value;
|
|
}
|
|
|
|
public Vec3bImmutable(byte x, byte y, byte z) {
|
|
this.x = x;
|
|
this.y = y;
|
|
this.z = z;
|
|
}
|
|
|
|
@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 Vec3b setX(byte x) { return this.x == x ? this : Vec3b.of(x, y, z); }
|
|
@Override
|
|
public Vec3b setY(byte y) { return this.y == y ? this : Vec3b.of(x, y, z); }
|
|
@Override
|
|
public Vec3b setZ(byte z) { return this.z == z ? this : Vec3b.of(x, y, z); }
|
|
@Override
|
|
public Vec3b copy() { return Vec3b.of(this); }
|
|
@Override
|
|
public Vec3b set(byte x, byte y, byte z) { return this.x == x && this.y == y && this.z == z ? this : Vec3b.of(x, y, z); }
|
|
@Override
|
|
public int hashCode() { return Objects.hash(x, y, z); }
|
|
@Override
|
|
public boolean equals(Object obj) {
|
|
if(obj instanceof Vec3b) {
|
|
Vec3b vec = (Vec3b)obj;
|
|
return vec.getX() == x && vec.getY() == y && vec.getZ() == z;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public String toString() { return "Vec3b[x="+x+", y="+y+", z="+z+"]"; }
|
|
}
|