Coverage Report - org.apache.maven.toolchain.DefaultToolchain
 
Classes in this File Line Coverage Branch Coverage Complexity
DefaultToolchain
0%
0/25
0%
0/8
1.714
 
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one
 3  
  * or more contributor license agreements.  See the NOTICE file
 4  
  * distributed with this work for additional information
 5  
  * regarding copyright ownership.  The ASF licenses this file
 6  
  * to you under the Apache License, Version 2.0 (the
 7  
  * "License"); you may not use this file except in compliance
 8  
  * with the License.  You may obtain a copy of the License at
 9  
  *
 10  
  *  http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing,
 13  
  * software distributed under the License is distributed on an
 14  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 15  
  * KIND, either express or implied.  See the License for the
 16  
  * specific language governing permissions and limitations
 17  
  * under the License.
 18  
  */
 19  
 
 20  
 package org.apache.maven.toolchain;
 21  
 
 22  
 import java.util.HashMap;
 23  
 import java.util.Iterator;
 24  
 import java.util.Map;
 25  
 import org.apache.maven.toolchain.model.ToolchainModel;
 26  
 import org.codehaus.plexus.logging.Logger;
 27  
 
 28  
 /**
 29  
  *
 30  
  * @author mkleint
 31  
  */
 32  
 public abstract class DefaultToolchain
 33  
     implements Toolchain, ToolchainPrivate
 34  
 {
 35  
 
 36  
     private String type;
 37  
 
 38  0
     private Map provides = new HashMap /*<String,RequirementMatcher>*/ (  );
 39  
 
 40  
     public static final String KEY_TYPE = "type"; //NOI18N
 41  
     
 42  
     private ToolchainModel model;
 43  
     
 44  
     private Logger logger;
 45  
 
 46  
     protected DefaultToolchain( ToolchainModel model, Logger logger ) 
 47  0
     {
 48  0
         this.model = model;
 49  
         
 50  0
         this.logger = logger;
 51  0
     }
 52  
 
 53  
     protected DefaultToolchain( ToolchainModel model, String type, Logger logger )
 54  
     {
 55  0
         this( model, logger );
 56  0
         this.type = type;
 57  0
     }
 58  
 
 59  
     public final String getType( )
 60  
     {
 61  0
         return type != null ? type : model.getType();
 62  
     }
 63  
 
 64  
     
 65  
     public final ToolchainModel getModel( ) 
 66  
     {
 67  0
         return model;
 68  
     }
 69  
 
 70  
     public final void addProvideToken( String type,
 71  
                                        RequirementMatcher matcher )
 72  
     {
 73  0
         provides.put( type, matcher );
 74  0
     }
 75  
 
 76  
 
 77  
     public boolean matchesRequirements(Map requirements) {
 78  0
         Iterator it = requirements.keySet().iterator();
 79  0
         while ( it.hasNext() )
 80  
         {
 81  0
             String key = (String) it.next();
 82  
             
 83  0
             RequirementMatcher matcher = (RequirementMatcher) provides.get(key);
 84  
             
 85  0
             if ( matcher == null )
 86  
             {
 87  0
                 getLog().debug( "Toolchain "  + this + " is missing required property: "  + key );
 88  0
                 return false;
 89  
             }
 90  0
             if ( !matcher.matches( (String) requirements.get(key) ) )
 91  
             {
 92  0
                 getLog().debug( "Toolchain "  + this + " doesn't match required property: "  + key );
 93  0
                 return false;
 94  
             }
 95  0
         }
 96  0
         return true;
 97  
     }
 98  
     
 99  
     protected Logger getLog() {
 100  0
         return logger;
 101  
     }
 102  
 }