Class BooleanHelper


  • public final class BooleanHelper
    extends Object
    A collection of useful static methods to deal with booleans.
    Since:
    1.0
    Author:
    Mohammed Shaik Hussain Ali
    • Method Detail

      • getNullSafe

        public static Boolean getNullSafe​(Boolean bool)
        Returns a non-null boolean, even if the object being passed is a null boolean.

        If the passed-in object is a non-null boolean, then it is returned as-is.

        Example usage:
              Boolean bool1 = true;
              Boolean bool2 = null;
        
              Boolean bool3 = BooleanHelper.getNullSafe(bool1);
        
              Boolean bool4 = BooleanHelper.getNullSafe(bool2);
        
              // bool3 now contains the boolean: true
              // bool4 now contains the boolean: false
         
        Parameters:
        bool - The boolean to safeguard against null.
        Returns:
        If bool is null then Boolean.FALSE.
        Since:
        1.0