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 BigDecimalToLongConverter implements TypeConverter<BigDecimal, Long> {
    @Override
    public Optional<Long> convert(BigDecimal object, Class<Long> targetType, ConversionContext context) {
        return Optional.ofNullable(object != null ? object.longValue() : null);
    }
}
