title: Converting configuration properties to enum values
body: <p>I have a configuration file which contains this line:</p>
  
  <pre><code>login.mode=PASSWORD
  </code></pre>
  
  <p>and an enum</p>
  
  <pre><code>public enum LoginMode {
  PASSWORD, NOT_PASSWORD, OTHER }
  </code></pre>
  
  <p>and a spring bean</p>
  
  <pre><code>&lt;bean id="environment" class="a.b.c.Environment" init-method="init"&gt;
    &lt;property name="loginMode" value="${login.mode}"/&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>and of course a bean class</p>
  
  <pre><code>public class Environment {
      private LoginMode loginMode;
  
      public LoginMode getLoginMode() {
          return loginMode;
      }
  
      public void setLoginMode(LoginMode loginMode) {
          this.loginMode = loginMode;
      }
  }
  </code></pre>
  
  <p>How can i convert the property of the configuration file (which is a String) into the corresponding enum value of LoginMode?</p>
  
  <p>EDIT: i know how to get the enum value of a string input, but the issue is another one:
  If i try this:</p>
  
  <pre><code>public class Environment {
      private LoginMode loginMode;
  
      public LoginMode getLoginMode() {
          return loginMode;
      }
  
      public void setLoginMode(String loginMode) {
          this.loginMode = LoginMode.valueOf(loginMode);
      }
  }
  </code></pre>
  
  <p>spring is complaining about getter and setter not having the same input and output type.</p>
  
  <pre><code>Bean property 'loginMode' is not writable or has an invalid setter method. Does the    parameter type of the setter match the return type of the getter?
  </code></pre>