title: How to create typesafe user roles for Spring Security?
body: <p>I'd like to make use of <code>spring-security</code> with <code>ROLE_ADMIN</code> and <code>ROLE_USER</code> roles.</p>
  
  <p>I therefore try to create a typesafe enum class, but the <code>@Secured</code> annotation requires a constant <code>String</code>, which I cannot achieve by using an enum class.</p>
  
  <p>What could I change in the following code?</p>
  
  <pre><code>public enum UserRole {
      ADMIN("ROLE_ADMIN");
  
      private String role;
  
      public UserRole(String role) {  
          this.role = role;
      }
  }
  
  //error: The value for annotation attribute Secured.value must be a constant expression
  @Secured(USerRole.ADMIN.value())
  public class SecuredView {
  
  }
  </code></pre>