package com.ruoyi.mill.protocol;

/**
 * 电文字段描述符（与 Excel 字段定义一一对应）
 */
public class FieldDef {

    private final String name;
    private final FieldType type;
    /** 字符型长度（字节数）；整型固定4，浮点固定4，长整型固定8 */
    private final int length;
    /** 浮点精度（仅用于格式化输出，编解码不依赖此值） */
    private final int precision;

    public FieldDef(String name, FieldType type, int length, int precision) {
        this.name = name;
        this.type = type;
        this.length = length;
        this.precision = precision;
    }

    public String getName()    { return name; }
    public FieldType getType() { return type; }
    public int getLength()     { return type == FieldType.STRING ? length : type == FieldType.LONG ? 8 : 4; }
    public int getPrecision()  { return precision; }
}
