class ObjectCoercer {

    public static float coerceNumberObjectToFloatPrimitive(Object numberObject) {
        if (numberObject == null) {
            return 0;
        }

        if (numberObject instanceof Integer) {
            Integer number = (Integer) numberObject;
            return number.floatValue();
        } else if (numberObject instanceof Double) {
            Double number = (Double) numberObject;
            return number.floatValue();
        } else if (numberObject instanceof Long) {
            Long number = (Long) numberObject;
            return number.floatValue();
        } else {
            float finalValue;
            try {
                finalValue = (float) numberObject;
            } catch (ClassCastException e) {
                finalValue = 0f;
            }

            return finalValue;
        }
    }

}