212 if (obj instanceof Boolean) { 213 return value == ((Boolean)obj).booleanValue(); 214 } 215 return false; 216 } 217 218 /** 219 * Returns {@code true} if and only if the system property 220 * named by the argument exists and is equal to the string 221 * {@code "true"}. (Beginning with version 1.0.2 of the 222 * Java<small><sup>TM</sup></small> platform, the test of 223 * this string is case insensitive.) A system property is accessible 224 * through {@code getProperty}, a method defined by the 225 * {@code System} class. 226 * <p> 227 * If there is no property with the specified name, or if the specified 228 * name is empty or null, then {@code false} is returned. 229 * 230 * @param name the system property name. 231 * @return the {@code boolean} value of the system property. 232 * @see java.lang.System#getProperty(java.lang.String) 233 * @see java.lang.System#getProperty(java.lang.String, java.lang.String) 234 */ 235 public static boolean getBoolean(String name) { 236 boolean result = false; 237 try { 238 result = toBoolean(System.getProperty(name)); 239 } catch (IllegalArgumentException e) { 240 } catch (NullPointerException e) { 241 } 242 return result; 243 } 244 245 /** 246 * Compares this {@code Boolean} instance with another. 247 * 248 * @param b the {@code Boolean} instance to be compared 249 * @return zero if this object represents the same boolean value as the 250 * argument; a positive value if this object represents true 251 * and the argument represents false; and a negative value if 252 * this object represents false and the argument represents true 253 * @throws NullPointerException if the argument is {@code null} 254 * @see Comparable 255 * @since 1.5 256 */ 257 public int compareTo(Boolean b) { 258 return compare(this.value, b.value); 259 } 260 | 212 if (obj instanceof Boolean) { 213 return value == ((Boolean)obj).booleanValue(); 214 } 215 return false; 216 } 217 218 /** 219 * Returns {@code true} if and only if the system property 220 * named by the argument exists and is equal to the string 221 * {@code "true"}. (Beginning with version 1.0.2 of the 222 * Java<small><sup>TM</sup></small> platform, the test of 223 * this string is case insensitive.) A system property is accessible 224 * through {@code getProperty}, a method defined by the 225 * {@code System} class. 226 * <p> 227 * If there is no property with the specified name, or if the specified 228 * name is empty or null, then {@code false} is returned. 229 * 230 * @param name the system property name. 231 * @return the {@code boolean} value of the system property. 232 * @throws SecurityException for the same reasons as 233 * {@link System#getProperty(String) System.getProperty} 234 * @see java.lang.System#getProperty(java.lang.String) 235 * @see java.lang.System#getProperty(java.lang.String, java.lang.String) 236 */ 237 public static boolean getBoolean(String name) { 238 boolean result = false; 239 try { 240 result = toBoolean(System.getProperty(name)); 241 } catch (IllegalArgumentException | NullPointerException e) { 242 } 243 return result; 244 } 245 246 /** 247 * Compares this {@code Boolean} instance with another. 248 * 249 * @param b the {@code Boolean} instance to be compared 250 * @return zero if this object represents the same boolean value as the 251 * argument; a positive value if this object represents true 252 * and the argument represents false; and a negative value if 253 * this object represents false and the argument represents true 254 * @throws NullPointerException if the argument is {@code null} 255 * @see Comparable 256 * @since 1.5 257 */ 258 public int compareTo(Boolean b) { 259 return compare(this.value, b.value); 260 } 261 |