toad-java/src/main/java/dev.toad/ffi/u64.java

39 lines
704 B
Java
Raw Normal View History

package dev.toad.ffi;
2023-04-05 17:08:25 +00:00
import java.math.BigInteger;
public final class u64 {
2023-04-17 01:01:54 +00:00
public native byte[] toBytes();
2023-04-05 17:08:25 +00:00
public static final BigInteger MAX = BigInteger.TWO
.pow(64)
.subtract(BigInteger.ONE);
private final BigInteger l;
2023-04-05 17:08:25 +00:00
public u64(BigInteger l) {
uint.assertWithinRange(this.MAX, l);
this.l = l;
}
2023-04-05 17:08:25 +00:00
public u64(long l) {
this(BigInteger.valueOf(l));
}
public BigInteger bigintValue() {
return this.l;
}
2023-04-20 06:58:11 +00:00
@Override
public boolean equals(Object other) {
return switch (other) {
case u64 o -> this.equals(o);
default -> false;
};
}
public boolean equals(u64 other) {
return this.bigintValue() == other.bigintValue();
}
}