package jumapacelaya.gob.mx.predios.convertidor;

import io.micronaut.core.convert.TypeConverter;
import io.micronaut.core.convert.ConversionContext;
import jakarta.inject.Singleton;

import java.math.BigDecimal;
import java.util.Optional;

@Singleton
public class BigDecimalToDoubleConverter implements TypeConverter<BigDecimal, Double> {
    @Override
    public Optional<Double> convert(BigDecimal object, Class<Double> targetType, ConversionContext context) {
        return Optional.ofNullable(object != null ? object.doubleValue() : null);
    }
}
