Coverage Report - org.apache.maven.index.treeview.TreeViewRequest
 
Classes in this File Line Coverage Branch Coverage Complexity
TreeViewRequest
61 %
16/26
33 %
4/12
1,5
 
 1  
 package org.apache.maven.index.treeview;
 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 java.util.HashMap;
 23  
 import java.util.Map;
 24  
 
 25  
 import org.apache.maven.index.ArtifactInfoFilter;
 26  
 import org.apache.maven.index.Field;
 27  
 import org.apache.maven.index.MAVEN;
 28  
 import org.apache.maven.index.context.IndexingContext;
 29  
 
 30  
 public class TreeViewRequest
 31  
 {
 32  
     private final TreeNodeFactory factory;
 33  
 
 34  
     private final String path;
 35  
 
 36  
     private final ArtifactInfoFilter artifactInfoFilter;
 37  
 
 38  
     private final Map<Field, String> fieldHints;
 39  
 
 40  
     private final IndexingContext indexingContext;
 41  
 
 42  
     public TreeViewRequest( final TreeNodeFactory factory, final String path, final IndexingContext ctx )
 43  
     {
 44  5
         this( factory, path, null, null, ctx );
 45  5
     }
 46  
 
 47  
     public TreeViewRequest( final TreeNodeFactory factory, final String path, final Map<Field, String> hints,
 48  
                             final ArtifactInfoFilter artifactInfoFilter, final IndexingContext ctx )
 49  47
     {
 50  47
         this.factory = factory;
 51  
 
 52  47
         this.path = path;
 53  
 
 54  47
         this.fieldHints = new HashMap<Field, String>();
 55  
 
 56  47
         if ( hints != null && hints.size() != 0 )
 57  
         {
 58  0
             this.fieldHints.putAll( hints );
 59  
         }
 60  
 
 61  47
         this.artifactInfoFilter = artifactInfoFilter;
 62  
 
 63  47
         this.indexingContext = ctx;
 64  47
     }
 65  
 
 66  
     public TreeNodeFactory getFactory()
 67  
     {
 68  301
         return factory;
 69  
     }
 70  
 
 71  
     public String getPath()
 72  
     {
 73  291
         return path;
 74  
     }
 75  
 
 76  
     public ArtifactInfoFilter getArtifactInfoFilter()
 77  
     {
 78  113
         return artifactInfoFilter;
 79  
     }
 80  
 
 81  
     public void addFieldHint( Field field, String hint )
 82  
     {
 83  0
         fieldHints.put( field, hint );
 84  0
     }
 85  
 
 86  
     public void removeFieldHint( Field field )
 87  
     {
 88  0
         fieldHints.remove( field );
 89  0
     }
 90  
 
 91  
     public boolean hasFieldHints()
 92  
     {
 93  139
         return fieldHints.size() > 0 && ( hasFieldHint( MAVEN.GROUP_ID ) );
 94  
     }
 95  
 
 96  
     public boolean hasFieldHint( Field... fields )
 97  
     {
 98  0
         for ( Field f : fields )
 99  
         {
 100  0
             if ( !fieldHints.containsKey( f ) )
 101  
             {
 102  0
                 return false;
 103  
             }
 104  
         }
 105  
 
 106  0
         return true;
 107  
     }
 108  
 
 109  
     public String getFieldHint( Field field )
 110  
     {
 111  0
         return fieldHints.get( field );
 112  
     }
 113  
 
 114  
     public Map<Field, String> getFieldHints()
 115  
     {
 116  42
         return fieldHints;
 117  
     }
 118  
 
 119  
     public IndexingContext getIndexingContext()
 120  
     {
 121  160
         return indexingContext;
 122  
     }
 123  
 }