package org.example.Entity.Control.Fields;


import com.fasterxml.jackson.annotation.JsonInclude;
import org.example.Utils.DataTableUtil;

import java.util.Map;

@JsonInclude(JsonInclude.Include.NON_NULL)
public class TextField extends Field {
    private String _emptyText;
    private String type;

    public TextField(Map<String, Object> row) {
        super(row);
        this.defaultXtype = "textfield";
    }

    @Override
    public String getXtype() {
        if (getName() == null || getName().isEmpty()) {
            super.setXtype("displayfield");
        }
        return super.getXtype();
    }

    @Override
    public void setXtype(String xtype) {
        super.setXtype(xtype);
    }

    @JsonInclude(JsonInclude.Include.NON_NULL)
    public Integer getMaxLength() {
        Object m = DataTableUtil.getRowVal(_row, "limitmaxvalue", null);
        return m != null && (Integer) m == 0 ? null : (Integer) m;
    }

    @JsonInclude(JsonInclude.Include.NON_NULL)
    public String getEmptyText() {
        return _emptyText;
    }

    public void setEmptyText(String emptyText) {
        this._emptyText = emptyText;
    }

    @JsonInclude(JsonInclude.Include.NON_NULL)
    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }


}