@FFDCIgnore(Exception.class)
    public static long parseLong(Object configAlias, String propertyKey, Object obj, long defaultValue) {
        if (obj != null) {
            try {
                if (obj instanceof String)
                    return Long.parseLong((String) obj);
                else if (obj instanceof Short)
                    return ((Short) obj).longValue();
                else if (obj instanceof Integer)
                    return ((Integer) obj).longValue();
                else if (obj instanceof Long)
                    return (Long) obj;
            } catch (Exception e) {
                Tr.warning(tc, "invalidLong", configAlias, propertyKey, obj);
                throw new IllegalArgumentException("Long value could not be parsed: key=" + propertyKey + ", value=" + obj, e);
            }

            // unknown type
            Tr.warning(tc, "invalidLong", configAlias, propertyKey, obj);
            throw new IllegalArgumentException("Long value could not be parsed: key=" + propertyKey + ", value=" + obj);
        }

        return defaultValue;
    }
@ FFDCIgnore ( Exception . class ) public static long parseLong ( Object configAlias , String propertyKey , Object obj , long defaultValue ) { if ( obj != null ) { try { if ( obj instanceof String ) return Long . parseLong ( ( String ) obj ) ; else if ( obj instanceof Short ) return ( ( Short ) obj ) . longValue ( ) ; else if ( obj instanceof Integer ) return ( ( Integer ) obj ) . longValue ( ) ; else if ( obj instanceof Long ) return ( Long ) obj ; } catch ( Exception e ) { Tr . warning ( tc , "invalidLong" , configAlias , propertyKey , obj ) ; throw new IllegalArgumentException ( "Long value could not be parsed: key=" + propertyKey + ", value=" + obj , e ) ; } Tr . warning ( tc , "invalidLong" , configAlias , propertyKey , obj ) ; throw new IllegalArgumentException ( "Long value could not be parsed: key=" + propertyKey + ", value=" + obj ) ; } return defaultValue ; }
Parse a long 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 long
<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.
@param defaultValue
The default value that should be applied if the object is null.

@return Long parsed/retrieved from obj, or default value if obj is null
@throws IllegalArgumentException If value is not a String/Short/Integer/Long, or if an error
occurs while converting/casting the object to the return parameter type.