This project has retired. For details please refer to its Attic page.
MavenArtifactFacet xref
View Javadoc
1   package org.apache.archiva.metadata.model.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  import org.apache.commons.lang3.StringUtils;
24  
25  import java.util.HashMap;
26  import java.util.Map;
27  
28  public class MavenArtifactFacet
29      implements MetadataFacet
30  {
31      private String classifier;
32  
33      private String type;
34  
35      private String timestamp;
36  
37      private int buildNumber;
38  
39      public static final String FACET_ID = "org.apache.archiva.metadata.repository.storage.maven2.artifact";
40  
41      public String getClassifier()
42      {
43          return classifier;
44      }
45  
46      public void setClassifier( String classifier )
47      {
48          this.classifier = classifier;
49      }
50  
51      public String getType()
52      {
53          return type;
54      }
55  
56      public void setType( String type )
57      {
58          this.type = type;
59      }
60  
61      public String getTimestamp()
62      {
63          return timestamp;
64      }
65  
66      public void setTimestamp( String timestamp )
67      {
68          this.timestamp = timestamp;
69      }
70  
71      public int getBuildNumber()
72      {
73          return buildNumber;
74      }
75  
76      public void setBuildNumber( int buildNumber )
77      {
78          this.buildNumber = buildNumber;
79      }
80  
81      @Override
82      public String getFacetId()
83      {
84          return FACET_ID;
85      }
86  
87      @Override
88      public String getName()
89      {
90          // TODO: not needed, perhaps artifact/version metadata facet should be separate interface?
91          return null;
92      }
93  
94      @Override
95      public Map<String, String> toProperties()
96      {
97          Map<String, String> properties = new HashMap<>();
98          properties.put( "type", type );
99          if ( classifier != null )
100         {
101             properties.put( "classifier", classifier );
102         }
103         if ( timestamp != null )
104         {
105             properties.put( "timestamp", timestamp );
106         }
107         if ( buildNumber > 0 )
108         {
109             properties.put( "buildNumber", Integer.toString( buildNumber ) );
110         }
111         return properties;
112     }
113 
114     @Override
115     public void fromProperties( Map<String, String> properties )
116     {
117         type = properties.get( "type" );
118         classifier = properties.get( "classifier" );
119         timestamp = properties.get( "timestamp" );
120         String buildNumber = properties.get( "buildNumber" );
121         if ( buildNumber != null )
122         {
123             this.buildNumber = Integer.parseInt( buildNumber );
124         }
125     }
126 
127     @Override
128     public boolean equals( Object o )
129     {
130         if ( this == o )
131         {
132             return true;
133         }
134         if ( !( o instanceof MavenArtifactFacet ) )
135         {
136             return false;
137         }
138 
139         MavenArtifactFacet./../../org/apache/archiva/metadata/model/maven2/MavenArtifactFacet.html#MavenArtifactFacet">MavenArtifactFacet that = (MavenArtifactFacet) o;
140 
141         return StringUtils.equals( that.getClassifier(), this.classifier );
142     }
143 
144 }