diff --git a/btypes_big_integer/src/main/java/de/hhu/stups/btypes/BBoolean.java b/btypes_big_integer/src/main/java/de/hhu/stups/btypes/BBoolean.java index 82db10d8b4577cb0b552dc4e2436428789fea000..1d13c43584166086abf300a190c7fa274463cb3a 100755 --- a/btypes_big_integer/src/main/java/de/hhu/stups/btypes/BBoolean.java +++ b/btypes_big_integer/src/main/java/de/hhu/stups/btypes/BBoolean.java @@ -1,5 +1,7 @@ package de.hhu.stups.btypes; +import java.util.Objects; + public final class BBoolean implements BObject { public static final BBoolean TRUE = new BBoolean(true); @@ -19,6 +21,14 @@ public final class BBoolean implements BObject { return of(Boolean.parseBoolean(value)); } + public static BBoolean of(BBoolean value) { + return Objects.requireNonNull(value, "value"); + } + + /** + * Please use BBoolean.of(...) instead. + */ + @Deprecated public BBoolean(boolean value) { this.value = value; } diff --git a/btypes_big_integer/src/main/java/de/hhu/stups/btypes/BInteger.java b/btypes_big_integer/src/main/java/de/hhu/stups/btypes/BInteger.java index 38fa40948b0e42e1434858bc2381b52e89c6a142..acfd0dfcc744b1d81936466e1e89546220ea4113 100755 --- a/btypes_big_integer/src/main/java/de/hhu/stups/btypes/BInteger.java +++ b/btypes_big_integer/src/main/java/de/hhu/stups/btypes/BInteger.java @@ -1,12 +1,12 @@ package de.hhu.stups.btypes; -import java.math.BigInteger; -import java.util.Objects; - import clojure.lang.BigInt; import clojure.lang.RT; import clojure.lang.Var; +import java.math.BigInteger; +import java.util.Objects; + public final class BInteger extends Number implements Comparable<BInteger>, BObject { private static final BigInteger JBI_ZERO = BigInteger.ZERO; @@ -104,6 +104,22 @@ public final class BInteger extends Number implements Comparable<BInteger>, BObj this.value = Objects.requireNonNull(value, "value"); } + /** + * Please use BInteger.of(...) instead. + */ + @Deprecated + public BInteger(int value) { + this(of(value).value); + } + + /** + * Please use BInteger.of(...) instead. + */ + @Deprecated + public BInteger(String value) { + this(of(value).value); + } + @Override public boolean equals(Object obj) { if (this == obj) { @@ -120,11 +136,36 @@ public final class BInteger extends Number implements Comparable<BInteger>, BObj return this.value.hashCode(); } + @Override + public String toString() { + return this.value.toString(); + } + @Override public int compareTo(BInteger o) { return (int) COMPARE.invoke(this.value, o.value); } + @Override + public int intValue() { + return this.value.intValue(); + } + + @Override + public long longValue() { + return this.value.longValue(); + } + + @Override + public float floatValue() { + return this.value.floatValue(); + } + + @Override + public double doubleValue() { + return this.value.doubleValue(); + } + public BBoolean lessEqual(BInteger o) { return BBoolean.of(compareTo(o) <= 0); } @@ -149,34 +190,10 @@ public final class BInteger extends Number implements Comparable<BInteger>, BObj return BBoolean.of(compareTo(o) != 0); } - @Override - public int intValue() { - return this.value.intValue(); - } - - @Override - public long longValue() { - return this.value.longValue(); - } - - @Override - public float floatValue() { - return this.value.floatValue(); - } - - @Override - public double doubleValue() { - return this.value.doubleValue(); - } - public BInteger plus(BInteger o) { return of((BigInt) PLUS.invoke(this.value, o.value)); } - public String toString() { - return this.value.toString(); - } - public BInteger minus(BInteger o) { return of((BigInt) MINUS.invoke(this.value, o.value)); } diff --git a/btypes_primitives/src/main/java/de/hhu/stups/btypes/BBoolean.java b/btypes_primitives/src/main/java/de/hhu/stups/btypes/BBoolean.java index 48a8520538201a0c48761065bc341339887b7dd7..c7361c7670350ace1da2e918f550bcdd48a29202 100755 --- a/btypes_primitives/src/main/java/de/hhu/stups/btypes/BBoolean.java +++ b/btypes_primitives/src/main/java/de/hhu/stups/btypes/BBoolean.java @@ -1,5 +1,7 @@ package de.hhu.stups.btypes; +import java.util.Objects; + public final class BBoolean implements BObject { public static final BBoolean TRUE = new BBoolean(true); @@ -19,6 +21,14 @@ public final class BBoolean implements BObject { return of(Boolean.parseBoolean(value)); } + public static BBoolean of(BBoolean value) { + return Objects.requireNonNull(value, "value"); + } + + /** + * Please use BBoolean.of(...) instead. + */ + @Deprecated public BBoolean(boolean value) { this.value = value; } diff --git a/btypes_primitives/src/main/java/de/hhu/stups/btypes/BInteger.java b/btypes_primitives/src/main/java/de/hhu/stups/btypes/BInteger.java index 7adbd42524e99493486d4a0931752c8a159fe1b9..86fbe5be4ada7dd0bc2e27e97f64244fae3d312b 100644 --- a/btypes_primitives/src/main/java/de/hhu/stups/btypes/BInteger.java +++ b/btypes_primitives/src/main/java/de/hhu/stups/btypes/BInteger.java @@ -43,10 +43,22 @@ public final class BInteger extends Number implements Comparable<BInteger>, BObj private final int value; - private BInteger(int value) { + /** + * Please use BInteger.of(...) instead. + */ + @Deprecated + public BInteger(int value) { this.value = value; } + /** + * Please use BInteger.of(...) instead. + */ + @Deprecated + public BInteger(String value) { + this(of(value).value); + } + @Override public boolean equals(Object o) { if (this == o) { @@ -63,11 +75,36 @@ public final class BInteger extends Number implements Comparable<BInteger>, BObj return Integer.hashCode(value); } + @Override + public String toString() { + return String.valueOf(this.value); + } + @Override public int compareTo(BInteger o) { return Integer.compare(this.value, o.value); } + @Override + public int intValue() { + return this.value; + } + + @Override + public long longValue() { + return this.value; + } + + @Override + public float floatValue() { + return (float) this.value; + } + + @Override + public double doubleValue() { + return this.value; + } + public BBoolean lessEqual(BInteger o) { return BBoolean.of(this.value <= o.value); } @@ -92,34 +129,10 @@ public final class BInteger extends Number implements Comparable<BInteger>, BObj return BBoolean.of(this.value != o.value); } - @Override - public int intValue() { - return this.value; - } - - @Override - public long longValue() { - return this.value; - } - - @Override - public float floatValue() { - return (float) this.value; - } - - @Override - public double doubleValue() { - return this.value; - } - public BInteger plus(BInteger o) { return of(Math.addExact(this.value, o.value)); } - public String toString() { - return String.valueOf(this.value); - } - public BInteger minus(BInteger o) { return of(Math.subtractExact(this.value, o.value)); }