package com.haha.common.enums;

import lombok.Getter;

@Getter
public enum OpenType {

    IN("IN", "上货"),
    OUT("OUT", "消费");

    private final String code;
    private final String description;

    OpenType(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public static OpenType fromCode(String code) {
        if (code == null) {
            return null;
        }
        for (OpenType type : values()) {
            if (type.code.equals(code)) {
                return type;
            }
        }
        return null;
    }

    public static boolean isIn(String code) {
        return IN.code.equals(code);
    }

    public static boolean isOut(String code) {
        return OUT.code.equals(code);
    }
}
