title: Setting Java Enums values through dependency injection
body: <p>I created a class with a public nested enum class and some setters. The nested enum class uses variables with values from a properties file set through dependency injection to the outer class. I want the component that uses the outer class to be agnostic of the values of the enum and loop through each one individually. The enum will always be instantiated after the outer class so there's no worry about null values in the variables. I was told this isn't how enums are supposed to be used. The suggestion is to write a class that mimics the enum class instead of just using the enum. That seemed very dogmatic and I'm curious what people's thoughts are and possible alternatives. I had written something like:</p>
  
  <pre><code>public class myOuterClass {
      private static string1;
      private static string2;
      private static string3;
  
      public enum NestedEnum {
          MY_ENUM1("enum1: "+string1),
          MY_ENUM2("enum2: "+string2),
          MY_ENUM3("enum3: "+string3);
  
          private String enumValue = "";
  
          NestedEnum(String enumValue) {
              this.enumValue = enumValue;
          }
  
          public String getEnumValue() { return enumValue; }
      }
  
  
      public String printEnum(NestedEnum enum) {
          System.out.println(enum.getEnumValue());
          return enum.getEnumValue();
      }
  
  
      public void setString1(String string1) {
          this.string1 = string1;
      }
      public void setString2(String string2) {
          this.string2 = string2;
      }
      public void setString3(String string3) {
          this.string3 = string3;
      }
  }
  </code></pre>