package com.lantone.enums.med;

import com.diagbot.core.KeyedNamed;
import lombok.Setter;

/**
 * @Description:
 * @Author:zhaops
 * @time: 2021/6/15 13:20
 */
public enum MatchSourceEnum implements KeyedNamed {
    StandWord(1, "标准词"),
    SynonymsWord(2, "同义词"),
    Code(3,"编码"),
    History(4,"历史数据"),
    SimilarWord(5,"相似词");

    @Setter
    private int key;

    @Setter
    private String name;

    MatchSourceEnum(int key, String name) {
        this.key = key;
        this.name = name;
    }

    public static MatchSourceEnum getEnum(int key) {
        for (MatchSourceEnum item : MatchSourceEnum.values()) {
            if (item.key == key) {
                return item;
            }
        }
        return null;
    }

    public static MatchSourceEnum getEnum(String name) {
        for (MatchSourceEnum item : MatchSourceEnum.values()) {
            if (item.name.equals(name)) {
                return item;
            }
        }
        return null;
    }

    public static String getName(int key) {
        MatchSourceEnum item = getEnum(key);
        return item != null ? item.name : null;
    }

    public static Integer getKey(String name) {
        MatchSourceEnum item = getEnum(name);
        return item != null ? item.key : null;
    }

    @Override
    public int getKey() {
        return key;
    }

    @Override
    public String getName() {
        return name;
    }
}
