SimpleJavaEngine/src/main/java/speiger/src/coreengine/math/vector/longs/Vec4lImmutable.java

69 lines
1.6 KiB
Java

package speiger.src.coreengine.math.vector.longs;
import java.util.Objects;
public class Vec4lImmutable implements Vec4l {
final long x;
final long y;
final long z;
final long w;
public Vec4lImmutable() {
x = 0;
y = 0;
z = 0;
w = 0;
}
public Vec4lImmutable(long value) {
x = value;
y = value;
z = value;
w = value;
}
public Vec4lImmutable(long x, long y, long z, long w) {
this.x = x;
this.y = y;
this.z = z;
this.w = w;
}
@Override
public boolean isMutable() { return false; }
@Override
public long getX() { return x; }
@Override
public long getY() { return y; }
@Override
public long getZ() { return z; }
@Override
public long getW() { return w; }
@Override
public Vec4l setX(long x) { return this.x == x ? this : Vec4l.of(x, y, z, w); }
@Override
public Vec4l setY(long y) { return this.y == y ? this : Vec4l.of(x, y, z, w); }
@Override
public Vec4l setZ(long z) { return this.z == z ? this : Vec4l.of(x, y, z, w); }
@Override
public Vec4l setW(long w) { return this.w == w ? this : Vec4l.of(x, y, z, w); }
@Override
public Vec4l copy() { return Vec4l.of(this); }
@Override
public Vec4l set(long x, long y, long z, long w) { return this.x == x && this.y == y && this.z == z && this.w == w ? this : Vec4l.of(x, y, z, w); }
@Override
public int hashCode() { return Objects.hash(x, y, z, w); }
@Override
public boolean equals(Object obj) {
if(obj instanceof Vec4l) {
Vec4l vec = (Vec4l)obj;
return vec.getX() == x && vec.getY() == y && vec.getZ() == z && vec.getW() == w;
}
return false;
}
@Override
public String toString() { return "Vec4l[x="+x+", y="+y+", z="+z+", w="+w+"]"; }
}