package foundation.translator; import foundation.util.Util; public class ValueLength { private int length; private Integer decimalLength; public ValueLength() { } public ValueLength(int length) { this.length = length; } public static ValueLength getInstance(String value) { if (Util.isEmpty(value)) { return null; } String[] segments = value.split(","); if(segments.length == 0){ return null; } ValueLength result = new ValueLength(); result.length = Integer.parseInt(segments[0]); if (segments.length > 1) { result.decimalLength = Integer.parseInt(segments[1]); } return result; } public int getLength() { return length; } public void setLength(int length) { this.length = length; } public Integer getDecimalLength() { return decimalLength; } public void setDecimalLength(Integer decimalLength) { this.decimalLength = decimalLength; } public String toSQLSegment() { StringBuilder result = new StringBuilder(); result.append("("); result.append(length); if (decimalLength != null) { result.append(decimalLength); } result.append(")"); return result.toString(); } @Override public String toString() { return "ValueLength{" + "length=" + length + ", decimalLength=" + decimalLength + '}'; } }