View Javadoc

1   /*
2    * Copyright 2008-2013 smartics, Kronseder & Reiner GmbH
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package de.smartics.maven.issues.bugzilla;
17  
18  import org.apache.maven.artifact.versioning.ArtifactVersion;
19  import org.codehaus.plexus.util.StringUtils;
20  
21  import de.smartics.maven.issues.VersionType;
22  
23  /**
24   * Arbiter to determine if a version should be skipped from or included in a
25   * report.
26   *
27   * @author <a href="mailto:robert.reiner@smartics.de">Robert Reiner</a>
28   * @version $Revision:591 $
29   */
30  public abstract class AbstractVersionSkipper implements VersionSkipper
31  {
32    // ********************************* Fields *********************************
33  
34    // --- constants ------------------------------------------------------------
35  
36    // --- members --------------------------------------------------------------
37  
38    /**
39     * The configuration to control the rendering process.
40     */
41    protected final VersionType versionType;
42  
43    // ****************************** Initializer *******************************
44  
45    // ****************************** Constructors ******************************
46  
47    /**
48     * Default constructor.
49     *
50     * @param versionType the version type to be accepted.
51     */
52    public AbstractVersionSkipper(final VersionType versionType)
53    {
54      this.versionType = versionType;
55    }
56  
57    // ****************************** Inner Classes *****************************
58  
59    // ********************************* Methods ********************************
60  
61    // --- init -----------------------------------------------------------------
62  
63    // --- get&set --------------------------------------------------------------
64  
65    // --- business -------------------------------------------------------------
66  
67    /**
68     * If we render the report for a SNAPSHOT version we want to include issues
69     * fixed for the current target release that is the version without the
70     * SNAPHOT qualifier.
71     *
72     * @param releaseVersion the version about to be released.
73     * @param version the version to check if should be skipped.
74     * @return <code>true</code> if the release is a SNAPSHOT of the given
75     *         version.
76     */
77    protected boolean isReleaseSnapshotOfVersion(
78        final ArtifactVersion releaseVersion, final ArtifactVersion version)
79    {
80      final String qualifier = releaseVersion.getQualifier();
81      if (StringUtils.isNotBlank(qualifier))
82      {
83        final boolean isSnapshot = qualifier.contains("SNAPSHOT");
84        return (isSnapshot
85                && releaseVersion.getMajorVersion() == version.getMajorVersion()
86                && releaseVersion.getMinorVersion() == version.getMinorVersion() && releaseVersion
87            .getIncrementalVersion() == version.getIncrementalVersion());
88      }
89      return false;
90    }
91  
92    // --- object basics --------------------------------------------------------
93  
94  }