Breaking up a large Java enum

前端 未结 4 2069
时光取名叫无心
时光取名叫无心 2020-12-18 06:42

What is the recommended practice for taking a Java enum that has say 1300 values and putting it into organized groups? I know you can\'t just extends the enum group, so are

4条回答
  •  庸人自扰
    2020-12-18 07:43

    1300 values? Good god, who thought that was a good idea? Did it not occur to someone after 100 that it was getting too big?

    There's no good way around it that I can see. Get a shovel and start combining them into more cohesive sub-enums.

    Here's a question: How are they used? If they are part of your application configuration, I'd recommend moving them to a database rather than keeping them in code. They'll be more flexible that way.

提交回复
热议问题