All Downloads are FREE. Search and download functionalities are using the official Maven repository.

liqp.filters.Plus Maven / Gradle / Ivy

package liqp.filters;

class Plus extends Filter {

    /*
     * plus(input, operand)
     *
     * addition
     */
    @Override
    public Object apply(Object value, Object... params) {

        if(value == null) {
            value = 0L;
        }

        super.checkParams(params, 1);

        Object rhsObj = params[0];

        if (super.isInteger(value) && super.isInteger(rhsObj)) {
            return super.asNumber(value).longValue() + super.asNumber(rhsObj).longValue();
        }

        return super.asNumber(value).doubleValue() + super.asNumber(rhsObj).doubleValue();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy