java - How can I better represent user permissions? -


I have a square in my system (20?) final Define type permissions Booleans

What is a better way to do this?

I'm sure there are many examples about this, but I

You can take advantage of enums, for example:

  public enum permission {read, write; } Public Class User {Private Final Neemate & lt; Permission & gt; Permissions; Public user (permissions ... permissions) {this.permissions = EnumSet.copyOf (arrays.asList (permissions)); } Public Boolean entry (Permission permission) {Return permissions.Support (permission); } // ...} user user = new user (permission.red, permission.wITE);  

Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -