blob: 2be5b266cb281fbc759af5d7b0b4e9aa1e1ed26c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
/*******************************************************************************
* Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Wind River Systems - initial API and implementation
*******************************************************************************/
package org.eclipse.tcf.te.launch.core.lm;
import org.eclipse.core.runtime.Assert;
import org.eclipse.debug.core.ILaunchConfiguration;
/**
* Implementation of the Comparable interface for comparing launch configuration by their ranking.
*/
public class LaunchConfigSorter implements Comparable<LaunchConfigSorter> {
private final int ranking;
private final ILaunchConfiguration config;
/**
* Constructor.
*
* @param config The launch configuration. Must not be <code>null</code>
* @param ranking The launch configuration ranking.
*/
public LaunchConfigSorter(ILaunchConfiguration config, int ranking) {
Assert.isNotNull(config);
this.config = config;
this.ranking = ranking;
}
/**
* Returns the launch configuration.
*
* @return The launch configuration.
*/
public ILaunchConfiguration getConfig() {
return config;
}
/**
* Returns the launch configuration ranking.
*
* @return The launch configuration ranking.
*/
public int getRanking() {
return ranking;
}
/* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
return ranking;
}
/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
if (obj instanceof LaunchConfigSorter) {
return ranking == ((LaunchConfigSorter)obj).ranking;
}
return super.equals(obj);
}
/* (non-Javadoc)
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
@Override
public int compareTo(LaunchConfigSorter other) {
if (other.getRanking() > ranking) {
return 1;
} else if (other.getRanking() == ranking) {
return 0;
}
return -1;
}
}
|