package org.springblade.datasource.transform;

import lombok.AllArgsConstructor;
import lombok.Data;

@Data
@AllArgsConstructor
public class DefColumnSize {
    Integer defColumnSize;
    Integer defDecimalDigits;

    public static DefColumnSize parameterCorrection(DefColumnSize defColumnSize, Integer columnSize, Integer decimalDigits) {
        if (columnSize == null) {
            defColumnSize.setDefColumnSize(0);
            columnSize = 0;
        }
        if (columnSize < defColumnSize.getDefColumnSize()) {
            defColumnSize.setDefColumnSize(columnSize);
        }
        if (decimalDigits == null) {
            defColumnSize.setDefDecimalDigits(0);
            decimalDigits = 0;
        }
        if (decimalDigits < defColumnSize.getDefDecimalDigits()) {
            defColumnSize.setDefDecimalDigits(decimalDigits);
        }
        if (decimalDigits < (-83)) {
            defColumnSize.setDefDecimalDigits(-83);
        }
        return defColumnSize;
    }
}