Coverage Report - org.apache.maven.container.ContainerUtils
 
Classes in this File Line Coverage Branch Coverage Complexity
ContainerUtils
0 %
0/16
0 %
0/14
0
 
 1  
 package org.apache.maven.container;
 2  
 
 3  
 /*
 4  
  * Licensed to the Apache Software Foundation (ASF) under one
 5  
  * or more contributor license agreements.  See the NOTICE file
 6  
  * distributed with this work for additional information
 7  
  * regarding copyright ownership.  The ASF licenses this file
 8  
  * to you under the Apache License, Version 2.0 (the
 9  
  * "License"); you may not use this file except in compliance
 10  
  * with the License.  You may obtain a copy of the License at
 11  
  *
 12  
  *   http://www.apache.org/licenses/LICENSE-2.0
 13  
  *
 14  
  * Unless required by applicable law or agreed to in writing,
 15  
  * software distributed under the License is distributed on an
 16  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 17  
  * KIND, either express or implied.  See the License for the
 18  
  * specific language governing permissions and limitations
 19  
  * under the License.
 20  
  */
 21  
 
 22  
 import org.codehaus.plexus.PlexusContainer;
 23  
 import org.codehaus.plexus.component.repository.ComponentDescriptor;
 24  
 
 25  
 import java.util.HashMap;
 26  
 import java.util.LinkedHashMap;
 27  
 import java.util.Map;
 28  
 import java.util.Set;
 29  
 
 30  0
 public class ContainerUtils
 31  
 {
 32  
     
 33  
     public static Set<String> findChildComponentHints( String role, PlexusContainer parent, PlexusContainer child )
 34  
     {
 35  0
         return findChildComponents( role, parent, child ).keySet();
 36  
     }
 37  
     
 38  
     @SuppressWarnings( "unchecked" )
 39  
     public static Map<String, ComponentDescriptor> findChildComponents( String role, PlexusContainer parent, PlexusContainer child )
 40  
     {
 41  0
         Map<String, ComponentDescriptor> parentComponents = parent.getComponentDescriptorMap( role );
 42  0
         if ( parentComponents != null )
 43  
         {
 44  0
             parentComponents = new LinkedHashMap<String, ComponentDescriptor>( parentComponents );
 45  
         }
 46  
         
 47  0
         Map<String, ComponentDescriptor> childComponents = child.getComponentDescriptorMap( role );
 48  0
         if ( childComponents == null )
 49  
         {
 50  0
             return new HashMap<String, ComponentDescriptor>();
 51  
         }
 52  
         else
 53  
         {
 54  0
             childComponents = new LinkedHashMap<String, ComponentDescriptor>( childComponents );
 55  0
             if ( parentComponents != null && !parentComponents.isEmpty() )
 56  
             {
 57  0
                 for ( Map.Entry<String, ComponentDescriptor> entry : parentComponents.entrySet() )
 58  
                 {
 59  0
                     String hint = entry.getKey();
 60  
                     
 61  0
                     if ( childComponents.containsKey( hint ) && entry.getValue() == childComponents.get( hint ) )
 62  
                     {
 63  0
                         childComponents.remove( hint );
 64  
                     }
 65  0
                 }
 66  
             }
 67  
         }
 68  
         
 69  0
         return childComponents;
 70  
     }
 71  
 
 72  
 }