1 /*
2 * Copyright 2008-2010 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
17 package de.smartics.maven.issues.bugzilla;
18
19 import org.apache.maven.artifact.versioning.ArtifactVersion;
20 import org.codehaus.plexus.util.StringUtils;
21
22 import de.smartics.maven.issues.VersionType;
23
24 /**
25 * Arbiter to determine if a version should be skipped from or included in a
26 * report.
27 *
28 * @author <a href="mailto:robert.reiner@smartics.de">Robert Reiner</a>
29 * @version $Revision:591 $
30 */
31 public abstract class AbstractVersionSkipper implements VersionSkipper
32 {
33 // ********************************* Fields *********************************
34
35 // --- constants ------------------------------------------------------------
36
37 // --- members --------------------------------------------------------------
38
39 /**
40 * The configuration to control the rendering process.
41 */
42 protected final VersionType versionType;
43
44 // ****************************** Initializer *******************************
45
46 // ****************************** Constructors ******************************
47
48 /**
49 * Default constructor.
50 *
51 * @param versionType the version type to be accepted.
52 */
53 public AbstractVersionSkipper(final VersionType versionType)
54 {
55 this.versionType = versionType;
56 }
57
58 // ****************************** Inner Classes *****************************
59
60 // ********************************* Methods ********************************
61
62 // --- init -----------------------------------------------------------------
63
64 // --- get&set --------------------------------------------------------------
65
66 // --- business -------------------------------------------------------------
67
68 /**
69 * If we render the report for a SNAPSHOT version we want to include issues
70 * fixed for the current target release that is the version without the
71 * SNAPHOT qualifier.
72 *
73 * @param releaseVersion the version about to be released.
74 * @param version the version to check if should be skipped.
75 * @return <code>true</code> if the release is a SNAPSHOT of the given
76 * version.
77 */
78 protected boolean isReleaseSnapshotOfVersion(
79 final ArtifactVersion releaseVersion, final ArtifactVersion version)
80 {
81 final String qualifier = releaseVersion.getQualifier();
82 if (StringUtils.isNotBlank(qualifier))
83 {
84 final boolean isSnapshot = qualifier.contains("SNAPSHOT");
85 return (isSnapshot
86 && releaseVersion.getMajorVersion() == version.getMajorVersion()
87 && releaseVersion.getMinorVersion() == version.getMinorVersion() && releaseVersion
88 .getIncrementalVersion() == version.getIncrementalVersion());
89 }
90 return false;
91 }
92
93 // --- object basics --------------------------------------------------------
94
95 }