1 46 52 package org.mr.core.cmc; 53 54 55 56 61 public final class CMCRole { 62 63 private byte roles; 64 65 public static final CMCRole mantaAdmin = new CMCRole((byte)1); 66 public static final CMCRole viewer = new CMCRole((byte)2); 67 public static final CMCRole agentAdmin = new CMCRole((byte)4); 68 public static final CMCRole domainControllerAdmin = new CMCRole((byte)8); 69 70 71 CMCRole(byte role ){ 72 this.roles = role; 73 } 74 75 public CMCRole(CMCRole initRole){ 76 this(initRole.getRoles()); 77 } 78 79 84 public CMCRole addRole(CMCRole otherRole){ 85 this.setRoles((byte) (this.getRoles()|otherRole.getRoles())); 86 return this; 87 } 88 89 public boolean hasRole(CMCRole role){ 90 return (this.getRoles() & role.getRoles()) != 0; 91 } 92 93 94 95 96 97 100 protected byte getRoles() { 101 return roles; 102 } 103 104 107 protected void setRoles(byte roles) { 108 this.roles = roles; 109 } 110 111 } 112 | Popular Tags |