# java code snippets

枚举的巧妙用法

```java
public enum Env {

        INNER("inner") {
            @Override
            public String env() {
                return "";
            }
        },

        COMMON("common") {
            @Override
            public String env() {
                return "";
            }
        },

        TEST("test") {
            @Override
            public String env() {
                return "_test";
            }
        };

        public final String env;

        Env(String evn) {
            this.env = evn;
        }

        public abstract String env();

        public static Env of(final String evn) {
            Env[] envs = Env.values();
            for (Env env : envs) {
                if (env.env.equalsIgnoreCase(evn)) {
                    return env;
                }
            }
            throw new BossBizException("不合法的env:" + Objects.toString(evn));
        }
    }
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://book.rizon.top/xue-xi-bi-ji/java_code_snippets.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
