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
Post a Comment