package com.huashe.park.common.consts.enums;

import java.util.HashMap;
import java.util.Map;

/**
 * The enum Cons result.
 */
public enum ConsResult {
    /**
     * S cons result.
     */
    S(0, "S", "成功"),
    /**
     * X cons result.
     */
    X(1, "X", "失败"),
    /**
     * Sr cons result.
     */
    SR(2, "SR", "补桩成功");

    private final Integer code;

    private final String value;

    private final String info;

    private static final Map<Integer, ConsResult> dic = new HashMap<>();

    static {
        for (ConsResult status : values()) {
            dic.put(status.code, status);
        }
    }

    ConsResult(Integer code, String value, String info) {
        this.code = code;
        this.info = info;
        this.value = value;
    }

    /**
     * Gets code.
     *
     * @return the code
     */
    public Integer getCode() {
        return code;
    }

    /**
     * Gets value.
     *
     * @return the value
     */
    public String getValue() {
        return value;
    }

    /**
     * Gets info.
     *
     * @return the info
     */
    public String getInfo() {
        return info;
    }

    /**
     * Gets by code.
     *
     * @param code the code
     * @return the by code
     */
    public static ConsResult getByCode(Integer code) {
        if (!dic.containsKey(code)) {
            return X;
        }
        return dic.get(code);
    }
}
