< prev index next >

src/java.base/share/classes/java/lang/ModuleLayer.java

Print this page
rev 47483 : [mq]: XXXXXXX-double-trouble-2


 749      * @return The configuration for this layer
 750      */
 751     public Configuration configuration() {
 752         return cf;
 753     }
 754 
 755 
 756     /**
 757      * Returns the list of this layer's parents unless this is the
 758      * {@linkplain #empty empty layer}, which has no parents and so an
 759      * empty list is returned.
 760      *
 761      * @return The list of this layer's parents
 762      */
 763     public List<ModuleLayer> parents() {
 764         return parents;
 765     }
 766 
 767 
 768     /**
 769      * Returns an ordered stream of layers. The first element is is this layer,
 770      * the remaining elements are the parent layers in DFS order.
 771      *
 772      * @implNote For now, the assumption is that the number of elements will
 773      * be very low and so this method does not use a specialized spliterator.
 774      */
 775     Stream<ModuleLayer> layers() {
 776         List<ModuleLayer> allLayers = this.allLayers;
 777         if (allLayers != null)
 778             return allLayers.stream();
 779 
 780         allLayers = new ArrayList<>();
 781         Set<ModuleLayer> visited = new HashSet<>();
 782         Deque<ModuleLayer> stack = new ArrayDeque<>();
 783         visited.add(this);
 784         stack.push(this);
 785 
 786         while (!stack.isEmpty()) {
 787             ModuleLayer layer = stack.pop();
 788             allLayers.add(layer);
 789 




 749      * @return The configuration for this layer
 750      */
 751     public Configuration configuration() {
 752         return cf;
 753     }
 754 
 755 
 756     /**
 757      * Returns the list of this layer's parents unless this is the
 758      * {@linkplain #empty empty layer}, which has no parents and so an
 759      * empty list is returned.
 760      *
 761      * @return The list of this layer's parents
 762      */
 763     public List<ModuleLayer> parents() {
 764         return parents;
 765     }
 766 
 767 
 768     /**
 769      * Returns an ordered stream of layers. The first element is this layer,
 770      * the remaining elements are the parent layers in DFS order.
 771      *
 772      * @implNote For now, the assumption is that the number of elements will
 773      * be very low and so this method does not use a specialized spliterator.
 774      */
 775     Stream<ModuleLayer> layers() {
 776         List<ModuleLayer> allLayers = this.allLayers;
 777         if (allLayers != null)
 778             return allLayers.stream();
 779 
 780         allLayers = new ArrayList<>();
 781         Set<ModuleLayer> visited = new HashSet<>();
 782         Deque<ModuleLayer> stack = new ArrayDeque<>();
 783         visited.add(this);
 784         stack.push(this);
 785 
 786         while (!stack.isEmpty()) {
 787             ModuleLayer layer = stack.pop();
 788             allLayers.add(layer);
 789 


< prev index next >