1   package com.atlassian.plugins.codegen;
2   
3   import static com.google.common.base.Preconditions.checkNotNull;
4   
5   /**
6    * Describes a Maven plugin configuration element that should be added to the POM, specified
7    * as a group/artifact/version and an XML fragment that provides all other elements within the
8    * <plugin> element.  If the POM already contains a configuration for the same plugin,
9    * then only the <executions> element will be modified, adding any <execution>
10   * items whose IDs were not already present.
11   */
12  public class MavenPlugin implements PluginProjectChange
13  {
14      private final ArtifactId artifactId;
15      private final VersionId versionId;
16      private final String xmlContent;
17      
18      public static MavenPlugin mavenPlugin(ArtifactId artifactId, VersionId versionId, String xmlContent)
19      {
20          return new MavenPlugin(artifactId, versionId, xmlContent);
21      }
22      
23      private MavenPlugin(ArtifactId artifactId, VersionId versionId, String xmlContent)
24      {
25          this.artifactId = checkNotNull(artifactId, "artifactId");
26          this.versionId = checkNotNull(versionId, "versionId");
27          this.xmlContent = checkNotNull(xmlContent, "xmlContent");
28      }
29  
30      public ArtifactId getGroupAndArtifactId()
31      {
32          return artifactId;
33      }
34  
35      public VersionId getVersionId()
36      {
37          return versionId;
38      }
39      
40      public String getXmlContent()
41      {
42          return xmlContent;
43      }
44      
45      @Override
46      public String toString()
47      {
48          return "[Maven plugin: " + artifactId + "]"; 
49      }
50  }