public static Boolean toNullableBoolean ( Object value ) { if ( value == null ) return null ; if ( value instanceof Boolean ) return ( boolean ) value ; if ( value instanceof Duration ) return ( ( Duration ) value ) . toMillis ( ) > 0 ; String strValue = value . toString ( ) . toLowerCase ( ) ; if ( strValue . equals ( "1" ) || strValue . equals ( "true" ) || strValue . equals ( "t" ) || strValue . equals ( "yes" ) || strValue . equals ( "y" ) ) return true ; if ( strValue . equals ( "0" ) || strValue . equals ( "false" ) || strValue . equals ( "f" ) || strValue . equals ( "no" ) || strValue . equals ( "n" ) ) return false ; return null ; }
Converts value into boolean or returns null when conversion is not possible .