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

cleanup boolean

parent bc924438
No related branches found
No related tags found
1 merge request!66Refactor of Java BTypes
package de.hhu.stups.btypes;
import java.util.Objects;
public final class BBoolean implements BObject {
public class BBoolean implements BObject {
public static final BBoolean TRUE = new BBoolean(true);
public static final BBoolean FALSE = new BBoolean(false);
private final boolean value;
public static boolean parseBoolean(String s) {
return Boolean.parseBoolean(s);
public static BBoolean of(boolean value) {
if (value) {
return TRUE;
} else {
return FALSE;
}
public static String toString(boolean b) {
return Boolean.toString(b);
}
public static Boolean valueOf(boolean b) {
return Boolean.valueOf(b);
}
public int compareTo(Boolean b) {
return b.compareTo(value);
public static BBoolean of(String value) {
return of(Boolean.parseBoolean(value));
}
public static Boolean valueOf(String s) {
return Boolean.valueOf(s);
}
public static int compare(boolean x, boolean y) {
return Boolean.compare(x, y);
public BBoolean(boolean value) {
this.value = value;
}
public static boolean getBoolean(String name) {
return Boolean.getBoolean(name);
public BBoolean(String s) {
this(Boolean.parseBoolean(s));
}
public boolean booleanValue() {
return value;
return this.value;
}
@Override
public String toString() {
return String.valueOf(value);
public boolean equals(Object o) {
if (this == o) {
return true;
} else if (!(o instanceof BBoolean)) {
return false;
} else {
return this.value == ((BBoolean) o).value;
}
}
@Override
public int hashCode() {
return Objects.hash(value);
return Boolean.hashCode(this.value);
}
@Override
public boolean equals(Object obj) {
if(!(obj instanceof BBoolean)) {
return false;
}
if(((BBoolean) obj).booleanValue() != value) {
return false;
}
return true;
}
public BBoolean(boolean value) {
this.value = value;
}
public BBoolean(String s) {
this.value = Boolean.parseBoolean(s);
public String toString() {
return String.valueOf(this.value);
}
/* groovy operator overloading support */
@SuppressWarnings("rawtypes")
Object asType(Class clazz) {
if (clazz == new BBoolean(true).getClass()) {
return this.booleanValue();
}
Object asType(Class<?> clazz) {
if (clazz == BBoolean.class) {
return this;
}
return clazz.cast(this.value);
}
public BBoolean or(BBoolean other) {
return new BBoolean(this.booleanValue() || other.booleanValue());
}
public BBoolean or(Boolean other) {
public BBoolean or(boolean other) {
return new BBoolean(this.booleanValue() || other);
}
......@@ -88,7 +72,7 @@ public class BBoolean implements BObject {
return new BBoolean(this.booleanValue() ^ other.booleanValue());
}
public BBoolean xor(Boolean other) {
public BBoolean xor(boolean other) {
return new BBoolean(this.booleanValue() ^ other);
}
......@@ -96,7 +80,7 @@ public class BBoolean implements BObject {
return new BBoolean(this.booleanValue() && other.booleanValue());
}
public BBoolean and(Boolean other) {
public BBoolean and(boolean other) {
return new BBoolean(this.booleanValue() && other);
}
......@@ -108,31 +92,31 @@ public class BBoolean implements BObject {
return this.not().or(other);
}
public BBoolean implies(Boolean other) {
public BBoolean implies(boolean other) {
return new BBoolean(this.not().booleanValue() || other);
}
public BBoolean equivalent(BBoolean other) {
return this.implies(other).and(other.implies(this));
return new BBoolean(this.booleanValue() == other.booleanValue());
}
public BBoolean equivalent(Boolean other) {
public BBoolean equivalent(boolean other) {
return new BBoolean(this.booleanValue() == other);
}
public BBoolean equal(BBoolean other) {
return new BBoolean(this.value == other.value);
return new BBoolean(this.booleanValue() == other.booleanValue());
}
public BBoolean unequal(BBoolean other) {
return new BBoolean(this.value != other.value);
return new BBoolean(this.booleanValue() != other.booleanValue());
}
public BBoolean isBoolean() {
return new BBoolean(true);
return TRUE;
}
public BBoolean isNotBoolean() {
return new BBoolean(false);
return FALSE;
}
}
package de.hhu.stups.btypes;
public final class BUtils {
public class BUtils {
public static final BSet<BBoolean> BOOL = new BSet<>(new BBoolean(true), new BBoolean(false));
public static final BSet<BBoolean> BOOL = new BSet<>(BBoolean.TRUE, BBoolean.FALSE);
private BUtils() {
}
}
package de.hhu.stups.btypes;
import java.util.Objects;
public final class BBoolean implements BObject {
public class BBoolean implements BObject {
public static final BBoolean TRUE = new BBoolean(true);
public static final BBoolean FALSE = new BBoolean(false);
private final boolean value;
public static boolean parseBoolean(String s) {
return Boolean.parseBoolean(s);
public static BBoolean of(boolean value) {
if (value) {
return TRUE;
} else {
return FALSE;
}
public static String toString(boolean b) {
return Boolean.toString(b);
}
public static Boolean valueOf(boolean b) {
return Boolean.valueOf(b);
}
public int compareTo(Boolean b) {
return b.compareTo(value);
public static BBoolean of(String value) {
return of(Boolean.parseBoolean(value));
}
public static Boolean valueOf(String s) {
return Boolean.valueOf(s);
}
public static int compare(boolean x, boolean y) {
return Boolean.compare(x, y);
public BBoolean(boolean value) {
this.value = value;
}
public static boolean getBoolean(String name) {
return Boolean.getBoolean(name);
public BBoolean(String s) {
this(Boolean.parseBoolean(s));
}
public boolean booleanValue() {
return value;
return this.value;
}
@Override
public String toString() {
return String.valueOf(value);
public boolean equals(Object o) {
if (this == o) {
return true;
} else if (!(o instanceof BBoolean)) {
return false;
} else {
return this.value == ((BBoolean) o).value;
}
}
@Override
public int hashCode() {
return Objects.hash(value);
return Boolean.hashCode(this.value);
}
@Override
public boolean equals(Object obj) {
if(!(obj instanceof BBoolean)) {
return false;
}
if(((BBoolean) obj).booleanValue() != value) {
return false;
}
return true;
}
public BBoolean(boolean value) {
this.value = value;
}
public BBoolean(String s) {
this.value = Boolean.parseBoolean(s);
public String toString() {
return String.valueOf(this.value);
}
/* groovy operator overloading support */
@SuppressWarnings("rawtypes")
Object asType(Class clazz) {
if (clazz == new BBoolean(true).getClass()) {
return this.booleanValue();
}
Object asType(Class<?> clazz) {
if (clazz == BBoolean.class) {
return this;
}
return clazz.cast(this.value);
}
public BBoolean or(BBoolean other) {
return new BBoolean(this.booleanValue() || other.booleanValue());
}
public BBoolean or(Boolean other) {
public BBoolean or(boolean other) {
return new BBoolean(this.booleanValue() || other);
}
......@@ -88,7 +72,7 @@ public class BBoolean implements BObject {
return new BBoolean(this.booleanValue() ^ other.booleanValue());
}
public BBoolean xor(Boolean other) {
public BBoolean xor(boolean other) {
return new BBoolean(this.booleanValue() ^ other);
}
......@@ -96,7 +80,7 @@ public class BBoolean implements BObject {
return new BBoolean(this.booleanValue() && other.booleanValue());
}
public BBoolean and(Boolean other) {
public BBoolean and(boolean other) {
return new BBoolean(this.booleanValue() && other);
}
......@@ -108,31 +92,31 @@ public class BBoolean implements BObject {
return this.not().or(other);
}
public BBoolean implies(Boolean other) {
public BBoolean implies(boolean other) {
return new BBoolean(this.not().booleanValue() || other);
}
public BBoolean equivalent(BBoolean other) {
return this.implies(other).and(other.implies(this));
return new BBoolean(this.booleanValue() == other.booleanValue());
}
public BBoolean equivalent(Boolean other) {
public BBoolean equivalent(boolean other) {
return new BBoolean(this.booleanValue() == other);
}
public BBoolean equal(BBoolean other) {
return new BBoolean(this.value == other.value);
return new BBoolean(this.booleanValue() == other.booleanValue());
}
public BBoolean unequal(BBoolean other) {
return new BBoolean(this.value != other.value);
return new BBoolean(this.booleanValue() != other.booleanValue());
}
public BBoolean isBoolean() {
return new BBoolean(true);
return TRUE;
}
public BBoolean isNotBoolean() {
return new BBoolean(false);
return FALSE;
}
}
package de.hhu.stups.btypes;
public final class BUtils {
public class BUtils {
public static final BSet<BBoolean> BOOL = new BSet<>(new BBoolean(true), new BBoolean(false));
public static final BSet<BBoolean> BOOL = new BSet<>(BBoolean.TRUE, BBoolean.FALSE);
private BUtils() {
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment