lttng: Rename lttng2 feature/plugins to lttng2.control
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.control.ui / src / org / eclipse / linuxtools / internal / lttng2 / control / ui / views / service / LttngVersion.java
1 /**********************************************************************
2 * Copyright (c) 2013 Ericsson
3 *
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * Bernd Hufmann - Initial API and implementation
11 **********************************************************************/
12 package org.eclipse.linuxtools.internal.lttng2.control.ui.views.service;
13
14 import org.osgi.framework.Version;
15
16 /**
17 * A version implementation with a special compareTo implementation
18 * to bypass problems of older implementation of org.osgi.framework.Version.
19 *
20 * @author Bernd Hufmann
21 */
22 public class LttngVersion extends Version {
23
24 /**
25 * Constructor
26 *
27 * @param version
28 * The version string
29 */
30 public LttngVersion(String version) {
31 super(version);
32 }
33
34 /**
35 * Special compareTo method to fix problem of older implementations of org.osgi.framework.Version
36 * where {@code Version.compareTo} takes an {@code Object} instead a {@code Version} as argument.
37 *
38 * @param other
39 * - Other version to compare
40 * @return a negative integer, zero, or a positive integer if this version
41 * is less than, equal to, or greater than the specified
42 * {@code LttngVersion} object.
43 */
44 public int compareTo(LttngVersion other) {
45 if (other == this) { // quicktest
46 return 0;
47 }
48
49 int result = getMajor() - other.getMajor();
50 if (result != 0) {
51 return result;
52 }
53
54 result = getMinor() - other.getMinor();
55 if (result != 0) {
56 return result;
57 }
58
59 result = getMicro() - other.getMicro();
60 if (result != 0) {
61 return result;
62 }
63 return getQualifier().compareTo(other.getQualifier());
64 }
65 }
This page took 0.047024 seconds and 5 git commands to generate.