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