package com.njcn.advance.responsibility.constant;

/**
 * 计算状态枚举
 * 
 * @author hongawen
 * @version 1.0
 */
public enum CalculationStatus {
    /**
     * 未计算
     */
    NOT_CALCULATED(0, "未计算"),
    
    /**
     * 计算完成
     */
    CALCULATED(1, "计算完成"),
    
    /**
     * 计算失败
     */
    FAILED(-1, "计算失败");
    
    private final int code;
    private final String description;
    
    CalculationStatus(int code, String description) {
        this.code = code;
        this.description = description;
    }
    
    public int getCode() {
        return code;
    }
    
    public String getDescription() {
        return description;
    }
    
    public static CalculationStatus fromCode(int code) {
        for (CalculationStatus status : values()) {
            if (status.code == code) {
                return status;
            }
        }
        return NOT_CALCULATED;
    }
}