package com.mcwl.common.enums;

import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.ToString;


@ToString
@AllArgsConstructor
@ApiModel(value = "返回对象", description = "返回状态")
public enum ResponseCodeEnum {

    FAILED_STATE_ENUM(0, "failed"),
    SUCCESS_STATE_ENUM(1, "success"),
    LOCK_STATE_ENUM(2, "lock"),
    PAY_SUCCESS_STATE_UPPER_CASE_ENUM(4, "SUCCESS"),
    PAY_FAIL_STATE_UPPER_CASE_ENUM(5, "FAIL"),
    UNLOCK_STATE_ENUM(3, "unlock");
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getIndex() {
        return index;
    }

    public void setIndex(int index) {
        this.index = index;
    }

    private String name;
    private int index;

    private ResponseCodeEnum(int index, String name) {
        this.index = index;
        this.name = name;
    }

    public static String getName(int index) {
        for (ResponseCodeEnum rkd : ResponseCodeEnum.values()) {
            if (rkd.index == index) {
                return rkd.name;
            }
        }

        return null;
    }

}
