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

io.vertx.up.uca.serialization.DecimalSaber Maven / Gradle / Ivy

There is a newer version: 0.9.0
Show newest version
package io.vertx.up.uca.serialization;

import io.vertx.up.fn.Fn;
import io.vertx.up.util.Ut;

import java.util.function.Function;

/**
 * Double, Float, BigDecimal
 */
public abstract class DecimalSaber extends BaseSaber {

    @Override
    public Object from(final Class paramType,
                       final String literal) {
        return Fn.getNull(() ->
                        Fn.getSemi(isValid(paramType), getLogger(),
                                () -> {
                                    verifyInput(!Ut.isDecimal(literal), paramType, literal);
                                    return getFun().apply(literal);
                                }, () -> 0.0),
                paramType, literal);
    }

    protected abstract boolean isValid(final Class paramType);

    protected abstract  Function getFun();
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy