com.opera.core.systems.common.lang
Class OperaBoolean

java.lang.Object
  extended by com.opera.core.systems.common.lang.OperaBoolean

public final class OperaBoolean
extends Object

Extension to Boolean which implements some convenience methods for interacting with "truthy" values from other, typically weakly typed, languages.

Author:
Andreas Tolf Tolfsen

Constructor Summary
OperaBoolean()
           
 
Method Summary
static boolean isBoolesque(String string)
          Whether string holds a boolean-like value.
static boolean parseBoolean(String string)
          Parses given string and returns its value as a boolean.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OperaBoolean

public OperaBoolean()
Method Detail

parseBoolean

public static boolean parseBoolean(String string)
Parses given string and returns its value as a boolean. A string which equals "1" or "true" is considered to be truthy.

Parameters:
string - string to parse
Returns:
true if string is truthy, false otherwise
Throws:
IllegalArgumentException - if parameter is not a boolesque value ("1", "true", "0", "false")
NullPointerException - if parameter is null

isBoolesque

public static boolean isBoolesque(String string)
Whether string holds a boolean-like value. It should equal "0", "1", "true" or "false". This method says nothing about whether the object is true or false.

Parameters:
string - string to check
Returns:
true if value is "boolesque", false otherwise
Throws:
IllegalArgumentException - if parameter is not a boolesque value ("1", "true", "0", "false")
NullPointerException - if parameter is null


Copyright © 2012. All Rights Reserved.