package cn.com.qmth.stmms.common.enums;

import java.util.LinkedList;
import java.util.List;

/**
 * 多评情况下的合分策略
 * 
 * @author luoshi
 *
 */
public enum ScorePolicy {
    AVG("平均分", 1), MAX("最高分", 2), MIN("最低分", 3), MIN_WITHOUT_ZERO("最低分(剔除0分)", 4);

    private String name;

    private int value;

    private static List<ScorePolicy> options;

    private ScorePolicy(String name, int value) {
        this.name = name;
        this.value = value;
    }

    public String getName() {
        return name;
    }

    public int getValue() {
        return value;
    }

    public static ScorePolicy findByValue(int value) {
        for (ScorePolicy c : ScorePolicy.values()) {
            if (c.getValue() == value) {
                return c;
            }
        }
        return null;
    }

    public static List<ScorePolicy> getOptionList() {
        if (options == null) {
            options = new LinkedList<>();
            for (ScorePolicy status : ScorePolicy.values()) {
                options.add(status);
            }
        }
        return options;
    }

    public static List<ScorePolicy> getList() {
        if (options == null) {
            options = new LinkedList<>();
            for (ScorePolicy status : ScorePolicy.values()) {
                if(!status.equals(ScorePolicy.MIN_WITHOUT_ZERO)){
                    options.add(status);
                }
            }
        }
        return options;
    }
}
