1 /* |
1 /* |
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
124 |
126 |
125 /** |
127 /** |
126 * Returns an enumeration of all the Permission objects in the collection. |
128 * Returns an enumeration of all the Permission objects in the collection. |
127 * |
129 * |
128 * @return an enumeration of all the Permissions. |
130 * @return an enumeration of all the Permissions. |
|
131 * @see #elementsAsStream() |
129 */ |
132 */ |
130 public abstract Enumeration<Permission> elements(); |
133 public abstract Enumeration<Permission> elements(); |
|
134 |
|
135 /** |
|
136 * Returns a stream of all the Permission objects in the collection. |
|
137 * |
|
138 * <p> The collection should not be modified (see {@link #add}) during the |
|
139 * execution of the terminal stream operation. Otherwise, the result of the |
|
140 * terminal stream operation is undefined. |
|
141 * |
|
142 * @implSpec |
|
143 * The default implementation creates a stream whose source is derived from |
|
144 * the enumeration returned from a call to {@link #elements()}. |
|
145 * |
|
146 * @return a stream of all the Permissions. |
|
147 * @since 1.9 |
|
148 */ |
|
149 public Stream<Permission> elementsAsStream() { |
|
150 int characteristics = isReadOnly() |
|
151 ? Spliterator.NONNULL | Spliterator.IMMUTABLE |
|
152 : Spliterator.NONNULL; |
|
153 return StreamSupport.stream( |
|
154 Spliterators.spliteratorUnknownSize( |
|
155 elements().asIterator(), characteristics), |
|
156 false); |
|
157 } |
131 |
158 |
132 /** |
159 /** |
133 * Marks this PermissionCollection object as "readonly". After |
160 * Marks this PermissionCollection object as "readonly". After |
134 * a PermissionCollection object |
161 * a PermissionCollection object |
135 * is marked as readonly, no new Permission objects can be added to it |
162 * is marked as readonly, no new Permission objects can be added to it |