Coverage Report - org.apache.maven.archetype.ui.ArchetypeDefinition
 
Classes in this File Line Coverage Branch Coverage Complexity
ArchetypeDefinition
79%
38/48
90%
9/10
1.12
 
 1  
 package org.apache.maven.archetype.ui;
 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.apache.maven.archetype.ArchetypeGenerationRequest;
 23  
 import org.codehaus.plexus.util.StringUtils;
 24  
 
 25  
 public class ArchetypeDefinition
 26  
 {
 27  
     private String groupId;
 28  
 
 29  
     private String artifactId;
 30  
 
 31  
     private String version;
 32  
 
 33  
     private String name;
 34  
 
 35  
     private String repository;
 36  
 
 37  
     private String goals;
 38  
 
 39  
     private String url;
 40  
 
 41  
     private String description;
 42  
 
 43  
     public ArchetypeDefinition()
 44  10
     {
 45  10
     }
 46  
 
 47  
     public ArchetypeDefinition( ArchetypeGenerationRequest request )
 48  16
     {
 49  16
         setGroupId( request.getArchetypeGroupId() );
 50  16
         setArtifactId( request.getArchetypeArtifactId() );
 51  16
         setVersion( request.getArchetypeVersion() );
 52  16
     }
 53  
 
 54  
     public String getArtifactId()
 55  
     {
 56  78
         return this.artifactId;
 57  
     }
 58  
 
 59  
     public String getGoals()
 60  
     {
 61  14
         return this.goals;
 62  
     }
 63  
 
 64  
     public String getGroupId()
 65  
     {
 66  128
         return this.groupId;
 67  
     }
 68  
 
 69  
     public String getName()
 70  
     {
 71  14
         return this.name;
 72  
     }
 73  
 
 74  
     public String getRepository()
 75  
     {
 76  16
         return this.repository;
 77  
     }
 78  
 
 79  
     public String getVersion()
 80  
     {
 81  74
         return this.version;
 82  
     }
 83  
 
 84  
     public String getUrl()
 85  
     {
 86  0
         return this.url;
 87  
     }
 88  
 
 89  
     public String getDescription()
 90  
     {
 91  0
         return this.description;
 92  
     }
 93  
 
 94  
     public void setArtifactId( String artifactId )
 95  
     {
 96  34
         this.artifactId = artifactId;
 97  34
     }
 98  
 
 99  
     public void setGoals( String goals )
 100  
     {
 101  4
         this.goals = goals;
 102  4
     }
 103  
 
 104  
     public void setGroupId( String groupId )
 105  
     {
 106  36
         this.groupId = groupId;
 107  36
     }
 108  
 
 109  
     public void setName( String name )
 110  
     {
 111  4
         this.name = name;
 112  4
     }
 113  
 
 114  
     public void setRepository( String repository )
 115  
     {
 116  2
         this.repository = repository;
 117  2
     }
 118  
 
 119  
     public void setVersion( String version )
 120  
     {
 121  36
         this.version = version;
 122  36
     }
 123  
 
 124  
     public void setUrl( String url )
 125  
     {
 126  0
         this.url = url;
 127  0
     }
 128  
 
 129  
     public void setDescription( String description )
 130  
     {
 131  0
         this.description = description;
 132  0
     }
 133  
 
 134  
     public void reset()
 135  
     {
 136  0
         setGroupId( null );
 137  0
         setArtifactId( null );
 138  0
         setVersion( null );
 139  0
     }
 140  
 
 141  
     public boolean isArtifactDefined()
 142  
     {
 143  28
         return StringUtils.isNotEmpty( getArtifactId() );
 144  
     }
 145  
 
 146  
     public boolean isDefined()
 147  
     {
 148  36
         return isPartiallyDefined() && isVersionDefined();
 149  
     }
 150  
 
 151  
     public boolean isGroupDefined()
 152  
     {
 153  60
         return StringUtils.isNotEmpty( getGroupId() );
 154  
     }
 155  
 
 156  
     public boolean isPartiallyDefined()
 157  
     {
 158  60
         return isGroupDefined() && isArtifactDefined();
 159  
     }
 160  
 
 161  
     public boolean isVersionDefined()
 162  
     {
 163  12
         return StringUtils.isNotEmpty( getVersion() );
 164  
     }
 165  
 
 166  
     public void updateRequest( ArchetypeGenerationRequest request )
 167  
     {
 168  10
         request.setArchetypeGroupId( getGroupId() );
 169  
 
 170  10
         request.setArchetypeArtifactId( getArtifactId() );
 171  
 
 172  10
         request.setArchetypeVersion( getVersion() );
 173  
 
 174  10
         request.setArchetypeGoals( getGoals() );
 175  
 
 176  10
         request.setArchetypeName( getName() );
 177  
 
 178  10
         if ( StringUtils.isNotEmpty( getRepository() ) )
 179  
         {
 180  2
             request.setArchetypeRepository( getRepository() );
 181  
         }
 182  10
     }
 183  
 }