public static boolean parseBoolean(Object configAlias, String propertyKey, Object obj, boolean defaultValue) {
        if (obj != null) {
            if (obj instanceof String) {
                String value = (String) obj;
                if (value.equalsIgnoreCase("true")) {
                    return true;
                } else if (value.equalsIgnoreCase("false")) {
                    return false;
                } else {
                    Tr.warning(tc, "invalidBoolean", configAlias, propertyKey, obj);
                    throw new IllegalArgumentException("Boolean value could not be parsed: key=" + propertyKey + ", value=" + obj);
                }
            } else if (obj instanceof Boolean) {
                return (Boolean) obj;
            }

            // unknown type
            Tr.warning(tc, "invalidBoolean", configAlias, propertyKey, obj);
            throw new IllegalArgumentException("Boolean value could not be parsed: key=" + propertyKey + ", value=" + obj);
        }
        return defaultValue;
    }
public static boolean parseBoolean ( Object configAlias , String propertyKey , Object obj , boolean defaultValue ) { if ( obj != null ) { if ( obj instanceof String ) { String value = ( String ) obj ; if ( value . equalsIgnoreCase ( "true" ) ) { return true ; } else if ( value . equalsIgnoreCase ( "false" ) ) { return false ; } else { Tr . warning ( tc , "invalidBoolean" , configAlias , propertyKey , obj ) ; throw new IllegalArgumentException ( "Boolean value could not be parsed: key=" + propertyKey + ", value=" + obj ) ; } } else if ( obj instanceof Boolean ) { return ( Boolean ) obj ; } Tr . warning ( tc , "invalidBoolean" , configAlias , propertyKey , obj ) ; throw new IllegalArgumentException ( "Boolean value could not be parsed: key=" + propertyKey + ", value=" + obj ) ; } return defaultValue ; }
Parse a boolean from the provided config value: checks for whether or not
the object read from the Service/Component configuration is a String
or a Metatype converted boolean.
<p>
If an exception occurs converting the object parameter:
A translated warning message will be issued using the provided propertyKey and object
as parameters. FFDC for the exception is suppressed: Callers should handle the thrown
IllegalArgumentException as appropriate.

@param configAlias
Name of config (pid or alias) associated with a registered service
or DS component.
@param propertyKey
The key used to retrieve the property value from the map.
Used in the warning message if the value is badly formed.
@param obj
The object retrieved from the configuration property map/dictionary.

@return boolean parsed from obj, the default value if obj is null.
@throws IllegalArgumentException If value is not a String/Boolean, or if the String
boolean is not "true" or "false" (ignoring case)