class ToLong
        implements Function {
    final Long defaultValue;

    public ToLong(Long defaultValue) {
        this.defaultValue = defaultValue;
    }

    @Override
    public Object apply(Object o) {<FILL_FUNCTION_BODY>}
}

        if (o == null) {
            return defaultValue;
        }

        if (o instanceof Boolean) {
            return (Boolean) o ? 1L : 0L;
        }

        if (o instanceof Number) {
            return ((Number) o).longValue();
        }

        throw new JSONException("can not cast to Long " + o.getClass());
    
<no_super_class>