package com.purui.prims.common.pojo;

import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Parameter {

    @ApiModelProperty(value = "名称")
    private String name;

    @ApiModelProperty(value = "默认值")
    private String defaultValue;

    @ApiModelProperty(value = "注释")
    private String comment;

    @ApiModelProperty(value = "描述")
    private String description;

    @ApiModelProperty(value = "数据类型")
    private String dataType;

    @ApiModelProperty(value = "模块")
    private String module;

    @ApiModelProperty(value = "值")
    private String value;

    @ApiModelProperty(value = "候选值")
    private List<Object> candidateValues;

    public Parameter(String name, String defaultValue, String comment,
                     String description, String dataType, String module) {
        this.name = name;
        this.defaultValue = defaultValue;
        this.comment = comment;
        this.description = description;
        this.dataType = dataType;
        this.module = module;
    }

    public Parameter(String name, String defaultValue, String comment, String description,
                     String dataType, String module, List<Object> candidateValues) {
        this.name = name;
        this.defaultValue = defaultValue;
        this.comment = comment;
        this.description = description;
        this.dataType = dataType;
        this.module = module;
        this.candidateValues = candidateValues;
    }

    public String getValue() {
        if (StringUtils.isBlank(value)) {
            return defaultValue;
        }
        return value;
    }

}
