/** * @return a new {@link AclEntry} * @throws IllegalStateException if type if null, or if type is either NAMED_USER or NAMED_GROUP * while subject is empty */ public AclEntry build() { if (mType == null) { throw new IllegalStateException("Type cannot be null"); } boolean subjectRequired = mType.equals(AclEntryType.NAMED_USER) || mType.equals(AclEntryType.NAMED_GROUP); if (subjectRequired && mSubject.isEmpty()) { throw new IllegalStateException("Subject for type " + mType + " cannot be empty"); } return new AclEntry(mType, mSubject, mActions, mIsDefault); } }
/** * @return the string representation for the CLI */ public String toCliString() { StringBuilder sb = new StringBuilder(); if (mIsDefault) { sb.append(DEFAULT_PREFIX); } sb.append(mType.toCliString()); sb.append(":"); if (mType == AclEntryType.NAMED_USER || mType == AclEntryType.NAMED_GROUP) { sb.append(mSubject); } sb.append(":"); sb.append(mActions.toCliString()); return sb.toString(); }