class ObjectCoercer {

    public static double coerceNumberObjectToDoublePrimitive(Object numberObject) {
        if (numberObject == null) {
            return 0;
        }

        if (numberObject instanceof Integer) {
            Integer number = (Integer) numberObject;
            return number.doubleValue();
        } else if (numberObject instanceof Float) {
            Float number = (Float) numberObject;
            return number.doubleValue();
        } else if (numberObject instanceof Long) {
            Long number = (Long) numberObject;
            return number.doubleValue();
        } else {
            double finalValue;
            try {
                finalValue = (double) numberObject;
            } catch (ClassCastException e) {
                finalValue = 0d;
            }

            return finalValue;
        }
    }

}