public static Boolean castBoolean ( Object o ) { if ( o == null ) { return null ; } if ( o instanceof Boolean ) { return ( Boolean ) o ; } else if ( o instanceof String ) { try { return Boolean . parseBoolean ( ( String ) o ) ; } catch ( IllegalArgumentException e ) { return null ; } } return null ; }
Casts a value to a boolean . May return null .