Skip to content
Snippets Groups Projects
Verified Commit 0cbd15ab authored by Miles Vella's avatar Miles Vella
Browse files

keep old public constructors of BInteger/BBoolean

parent cf8a88b7
No related branches found
No related tags found
1 merge request!66Refactor of Java BTypes
Pipeline #151246 passed
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;
}
......
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));
}
......
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;
}
......
......@@ -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));
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment