package com.xydl.cac.entity;

import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;

@JsonInclude(JsonInclude.Include.NON_NULL)
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table(name = "icd_config_type_inst")
@ApiModel("ICD配置类型实例表")
public class IcdConfigTypeInst {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Integer id;

    @ApiModelProperty(name = "配置类型表id")
    @Column(name = "icd_config_type_id")
    private Integer icdConfigTypeId;

    @ApiModelProperty(name = "实例")
    @Column(name = "inst")
    private String inst;

    @Transient
    private String paramIndex;

    @Transient
    private List<String> attList;

    public void addAtt(String att) {
        if (attList == null) {
            attList = new ArrayList<>();
        }
        if (!attList.contains(att)) {
            attList.add(att);
        }
    }

}