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.util;
18
19 import java.io.Serializable;
20 import java.util.Comparator;
21
22 import org.apache.maven.artifact.versioning.ArtifactVersion;
23
24 /**
25 * Inverts the natural order of the artifact version. Greater version numbers
26 * come first.
27 *
28 * @author <a href="mailto:robert.reiner@smartics.de">Robert Reiner</a>
29 * @version $Revision:591 $
30 */
31 public class InverseVersionComparator implements Comparator<ArtifactVersion>,
32 Serializable
33 {
34 // ********************************* Fields *********************************
35
36 // --- constants ------------------------------------------------------------
37
38 /**
39 * The class version identifier.
40 * <p>
41 * The value of this constant is {@value}.
42 */
43 private static final long serialVersionUID = 1L;
44
45 // --- members --------------------------------------------------------------
46
47 /**
48 * An instance for reuse.
49 */
50 public static final InverseVersionComparator INSTANCE =
51 new InverseVersionComparator();
52
53 // ****************************** Initializer *******************************
54
55 // ****************************** Constructors ******************************
56
57 /**
58 * Default constructor.
59 */
60 public InverseVersionComparator()
61 {
62 }
63
64 // ****************************** Inner Classes *****************************
65
66 // ********************************* Methods ********************************
67
68 // --- init -----------------------------------------------------------------
69
70 // --- get&set --------------------------------------------------------------
71
72 // --- business -------------------------------------------------------------
73
74 /**
75 * {@inheritDoc}
76 * <p>
77 * Returns the inverse natural order of the artifact version.
78 * </p>
79 */
80 @SuppressWarnings("unchecked")
81 public int compare(final ArtifactVersion o1, final ArtifactVersion o2)
82 {
83 return o2.compareTo(o1);
84 }
85
86 // --- object basics --------------------------------------------------------
87
88 }