2013-07-03 02:52:38 +00:00
|
|
|
/* Copyright (c) 2008-2013, Avian Contributors
|
2008-02-19 18:06:52 +00:00
|
|
|
|
|
|
|
Permission to use, copy, modify, and/or distribute this software
|
|
|
|
for any purpose with or without fee is hereby granted, provided
|
|
|
|
that the above copyright notice and this permission notice appear
|
|
|
|
in all copies.
|
|
|
|
|
|
|
|
There is NO WARRANTY for this software. See license.txt for
|
|
|
|
details. */
|
|
|
|
|
2007-07-20 03:18:25 +00:00
|
|
|
package java.lang;
|
|
|
|
|
2007-10-29 00:51:08 +00:00
|
|
|
public final class Boolean implements Comparable<Boolean> {
|
2013-02-22 18:55:01 +00:00
|
|
|
public static final Class TYPE = avian.Classes.forCanonicalName("Z");
|
2007-07-27 02:39:53 +00:00
|
|
|
|
2007-07-29 23:32:23 +00:00
|
|
|
public static final Boolean FALSE = new Boolean(false);
|
|
|
|
public static final Boolean TRUE = new Boolean(true);
|
|
|
|
|
2007-07-20 03:18:25 +00:00
|
|
|
private final boolean value;
|
|
|
|
|
|
|
|
public Boolean(boolean value) {
|
|
|
|
this.value = value;
|
|
|
|
}
|
|
|
|
|
2007-09-14 02:19:44 +00:00
|
|
|
public Boolean(String s) {
|
|
|
|
this.value = "true".equals(s);
|
|
|
|
}
|
|
|
|
|
2007-08-13 00:50:25 +00:00
|
|
|
public static Boolean valueOf(boolean value) {
|
|
|
|
return (value ? Boolean.TRUE : Boolean.FALSE);
|
|
|
|
}
|
|
|
|
|
2007-08-30 23:31:32 +00:00
|
|
|
public static Boolean valueOf(String s) {
|
2007-11-04 21:15:28 +00:00
|
|
|
Boolean.TRUE.booleanValue();
|
2007-08-30 23:31:32 +00:00
|
|
|
return ("true".equals(s) ? Boolean.TRUE : Boolean.FALSE);
|
|
|
|
}
|
|
|
|
|
2007-10-29 00:51:08 +00:00
|
|
|
public int compareTo(Boolean o) {
|
|
|
|
return (value ? (o.value ? 0 : 1) : (o.value ? -1 : 0));
|
|
|
|
}
|
|
|
|
|
2007-07-29 23:32:23 +00:00
|
|
|
public boolean equals(Object o) {
|
|
|
|
return o instanceof Boolean && ((Boolean) o).value == value;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int hashCode() {
|
|
|
|
return (value ? 1 : 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
public String toString() {
|
|
|
|
return toString(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static String toString(boolean v) {
|
|
|
|
return (v ? "true" : "false");
|
|
|
|
}
|
|
|
|
|
2007-07-20 03:18:25 +00:00
|
|
|
public boolean booleanValue() {
|
|
|
|
return value;
|
|
|
|
}
|
2013-10-17 20:03:34 +00:00
|
|
|
|
2013-10-25 18:25:46 +00:00
|
|
|
public static boolean getBoolean(String name) {
|
|
|
|
return parseBoolean(System.getProperty(name));
|
|
|
|
}
|
|
|
|
|
2013-10-17 20:03:34 +00:00
|
|
|
public static boolean parseBoolean(String string) {
|
|
|
|
return string != null && string.equalsIgnoreCase("true");
|
|
|
|
}
|
2007-07-20 03:18:25 +00:00
|
|
|
}
|