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