jdk/src/share/classes/java/nio/file/attribute/AclEntry.java
changeset 11358 8821bb789678
parent 9035 1255eb81cc2f
child 18574 4aeaeb541678
equal deleted inserted replaced
11357:0ef20e50a018 11358:8821bb789678
   173          * @throws  ClassCastException
   173          * @throws  ClassCastException
   174          *          if the set contains elements that are not of type {@code
   174          *          if the set contains elements that are not of type {@code
   175          *          AclEntryPermission}
   175          *          AclEntryPermission}
   176          */
   176          */
   177         public Builder setPermissions(Set<AclEntryPermission> perms) {
   177         public Builder setPermissions(Set<AclEntryPermission> perms) {
   178             // copy and check for erroneous elements
   178             if (perms.isEmpty()) {
   179             perms = EnumSet.copyOf(perms);
   179                 // EnumSet.copyOf does not allow empty set
   180             checkSet(perms, AclEntryPermission.class);
   180                 perms = Collections.emptySet();
       
   181             } else {
       
   182                 // copy and check for erroneous elements
       
   183                 perms = EnumSet.copyOf(perms);
       
   184                 checkSet(perms, AclEntryPermission.class);
       
   185             }
       
   186 
   181             this.perms = perms;
   187             this.perms = perms;
   182             return this;
   188             return this;
   183         }
   189         }
   184 
   190 
   185         /**
   191         /**
   210          * @throws  ClassCastException
   216          * @throws  ClassCastException
   211          *          if the set contains elements that are not of type {@code
   217          *          if the set contains elements that are not of type {@code
   212          *          AclEntryFlag}
   218          *          AclEntryFlag}
   213          */
   219          */
   214         public Builder setFlags(Set<AclEntryFlag> flags) {
   220         public Builder setFlags(Set<AclEntryFlag> flags) {
   215             // copy and check for erroneous elements
   221             if (flags.isEmpty()) {
   216             flags = EnumSet.copyOf(flags);
   222                 // EnumSet.copyOf does not allow empty set
   217             checkSet(flags, AclEntryFlag.class);
   223                 flags = Collections.emptySet();
       
   224             } else {
       
   225                 // copy and check for erroneous elements
       
   226                 flags = EnumSet.copyOf(flags);
       
   227                 checkSet(flags, AclEntryFlag.class);
       
   228             }
       
   229 
   218             this.flags = flags;
   230             this.flags = flags;
   219             return this;
   231             return this;
   220         }
   232         }
   221 
   233 
   222         /**
   234         /**