Live2D

枚举类

使用场景:希望根据某个key得到value以及更多信息

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
 * @Author NoDreamJava
 * @Date 2023-7-5 10:57
 * @Version 1.0
 */


@AllArgsConstructor
@NoArgsConstructor
@Getter
public enum SignOperation {
    UNION("union", "union all", "合并"),
    INTERSECT("intersect", "intersect", "交叉"),
    EXCEPT("except", "except", "排除");
    private String name;
    private String val;
    private String msg;

    public static SignOperation getByName(String name) {
        if (null != name) {
            for (SignOperation item : SignOperation.values()) {
                if (item.name.equals(name)) {
                    return item;
                }
            }
        }
        return null;
    }
}

class Test{
    public static void main(String[] args) {
        System.out.println(SignOperation.getByName("union").getMsg());
    }
}

posted @   没有梦想的java菜鸟  阅读(31)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
点击右上角即可分享
微信分享提示