package cn.axzo.msg.center.api.custombutton;

import cn.axzo.msg.center.service.enums.RouterButtonSourceEnum;
import lombok.Data;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/**
 * 提前设定的按钮
 *
 * @author yanglin
 */
@Data
public class ProposedButton {
    /**
     * 自定义按钮的key
     */
    private String buttonKey;
    /**
     * 自定义按钮的名称
     */
    private String buttonName;
    /**
     * 按钮类型
     */
    private RouterButtonSourceEnum source;
    /**
     * 提前设定的按钮配置
     */
    private List<ProposedButtonConfig> configs;

    public List<ProposedButtonConfig> determineConfigs() {
        return configs == null ? Collections.emptyList() : configs;
    }

    /**
     * 创建按钮
     */
    public static ProposedButton createButton(String buttonKey, ProposedButtonConfig... configs) {
        ProposedButton proposedButton = new ProposedButton();
        proposedButton.setButtonKey(buttonKey);
        proposedButton.setConfigs(configs == null ? Collections.emptyList() : Arrays.asList(configs));
        return proposedButton;
    }

    /**
     * 创建按钮
     */
    public static ProposedButton createButton(String buttonKey, List<ProposedButtonConfig> configs) {
        ProposedButton proposedButton = new ProposedButton();
        proposedButton.setButtonKey(buttonKey);
        proposedButton.setConfigs(configs);
        return proposedButton;
    }
}