title: How to check "hasRole" in Java Code with Spring Security?
body: <p>How to check user authority or permission in Java Code ? For example - I want to show or hide button for user depending on role. There are annotations like:</p>
  
  <pre><code>@PreAuthorize("hasRole('ROLE_USER')")
  </code></pre>
  
  <p>How to make it in Java code? Something like : </p>
  
  <pre><code>if(somethingHere.hasRole("ROLE_MANAGER")) {
     layout.addComponent(new Button("Edit users"));
  }
  </code></pre>