This project has retired. For details please refer to its Attic page.
MavenProjectFacet xref
View Javadoc
1   package org.apache.archiva.metadata.repository.storage.maven2;
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.archiva.metadata.model.MetadataFacet;
23  
24  import java.util.HashMap;
25  import java.util.Map;
26  
27  public class MavenProjectFacet
28      implements MetadataFacet
29  {
30      private String groupId;
31  
32      private String artifactId;
33  
34      private MavenProjectParent parent;
35  
36      private String packaging;
37  
38      public static final String FACET_ID = "org.apache.archiva.metadata.repository.storage.maven2.project";
39  
40      public String getGroupId()
41      {
42          return groupId;
43      }
44  
45      public void setGroupId( String groupId )
46      {
47          this.groupId = groupId;
48      }
49  
50      public String getArtifactId()
51      {
52          return artifactId;
53      }
54  
55      public void setArtifactId( String artifactId )
56      {
57          this.artifactId = artifactId;
58      }
59  
60      public MavenProjectParent getParent()
61      {
62          return parent;
63      }
64  
65      public void setParent( MavenProjectParent parent )
66      {
67          this.parent = parent;
68      }
69  
70      public String getPackaging()
71      {
72          return packaging;
73      }
74  
75      public void setPackaging( String packaging )
76      {
77          this.packaging = packaging;
78      }
79  
80      @Override
81      public String getFacetId()
82      {
83          return FACET_ID;
84      }
85  
86      @Override
87      public String getName()
88      {
89          // TODO: not needed, perhaps version metadata facet should be separate interface?
90          return null;
91      }
92  
93      @Override
94      public Map<String, String> toProperties()
95      {
96          HashMap<String, String> properties = new HashMap<>();
97          properties.put( "groupId", groupId );
98          properties.put( "artifactId", artifactId );
99          properties.put( "packaging", packaging );
100         if ( parent != null )
101         {
102             properties.put( "parent.groupId", parent.getGroupId() );
103             properties.put( "parent.artifactId", parent.getArtifactId() );
104             properties.put( "parent.version", parent.getVersion() );
105         }
106         return properties;
107     }
108 
109     @Override
110     public void fromProperties( Map<String, String> properties )
111     {
112         groupId = properties.get( "groupId" );
113         artifactId = properties.get( "artifactId" );
114         packaging = properties.get( "packaging" );
115         String parentArtifactId = properties.get( "parent.artifactId" );
116         if ( parentArtifactId != null )
117         {
118             MavenProjectParentository/storage/maven2/MavenProjectParent.html#MavenProjectParent">MavenProjectParent parent = new MavenProjectParent();
119             parent.setGroupId( properties.get( "parent.groupId" ) );
120             parent.setArtifactId( parentArtifactId );
121             parent.setVersion( properties.get( "parent.version" ) );
122             this.parent = parent;
123         }
124     }
125 
126     @Override
127     public boolean equals( Object o )
128     {
129         if ( this == o )
130         {
131             return true;
132         }
133         if ( !( o instanceof MavenProjectFacet ) )
134         {
135             return false;
136         }
137 
138         MavenProjectFacet../../../../org/apache/archiva/metadata/repository/storage/maven2/MavenProjectFacet.html#MavenProjectFacet">MavenProjectFacet that = (MavenProjectFacet) o;
139 
140         if ( !artifactId.equals( that.artifactId ) )
141         {
142             return false;
143         }
144         if ( !groupId.equals( that.groupId ) )
145         {
146             return false;
147         }
148         if ( !packaging.equals( that.packaging ) )
149         {
150             return false;
151         }
152 
153         return true;
154     }
155 
156     @Override
157     public int hashCode()
158     {
159         int result = groupId.hashCode();
160         result = 31 * result + artifactId.hashCode();
161         result = 31 * result + packaging.hashCode();
162         return result;
163     }
164 }