Commit | Line | Data |
---|---|---|
d04ec5a7 MK |
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 | * Matthew Khouzam - Initial API and implementation | |
11 | *******************************************************************************/ | |
12 | ||
13 | package org.eclipse.linuxtools.tmf.ui.project.model; | |
14 | ||
15 | /** | |
16 | * Trace import helper class | |
17 | * | |
18 | * @author Matthew Khouzam | |
19 | * @since 2.0 | |
20 | */ | |
21 | public class TraceValidationHelper implements Comparable<TraceValidationHelper> { | |
22 | ||
23 | private final String fTraceToScan; | |
24 | private final String fTraceType; | |
25 | ||
26 | /** | |
27 | * Trace To validate constructor | |
28 | * | |
29 | * @param traceToScan | |
30 | * the path of the trace | |
31 | * @param traceType | |
32 | * the trace type of the trace to add (canonical name) | |
33 | */ | |
34 | public TraceValidationHelper(String traceToScan, String traceType) { | |
35 | this.fTraceToScan = traceToScan; | |
36 | this.fTraceType = traceType; | |
37 | } | |
38 | ||
39 | /** | |
40 | * @return the trace filename | |
41 | */ | |
42 | public String getTraceToScan() { | |
43 | return fTraceToScan; | |
44 | } | |
45 | ||
46 | /** | |
47 | * @return the trace type canonical name | |
48 | */ | |
49 | public String getTraceType() { | |
50 | return fTraceType; | |
51 | } | |
52 | ||
53 | @Override | |
54 | public int hashCode() { | |
55 | final int prime = 31; | |
56 | int result = 1; | |
57 | result = prime * result + ((fTraceToScan == null) ? 0 : fTraceToScan.hashCode()); | |
58 | result = prime * result + ((fTraceType == null) ? 0 : fTraceType.hashCode()); | |
59 | return result; | |
60 | } | |
61 | ||
62 | @Override | |
63 | public boolean equals(Object obj) { | |
64 | if (this == obj) { | |
65 | return true; | |
66 | } | |
67 | if (obj == null) { | |
68 | return false; | |
69 | } | |
70 | if (!(obj instanceof TraceValidationHelper)) { | |
71 | return false; | |
72 | } | |
73 | TraceValidationHelper other = (TraceValidationHelper) obj; | |
74 | if (fTraceToScan == null) { | |
75 | if (other.fTraceToScan != null) { | |
76 | return false; | |
77 | } | |
78 | } else if (!fTraceToScan.equals(other.fTraceToScan)) { | |
79 | return false; | |
80 | } | |
81 | if (fTraceType == null) { | |
82 | if (other.fTraceType != null) { | |
83 | return false; | |
84 | } | |
85 | } else if (!fTraceType.equals(other.fTraceType)) { | |
86 | return false; | |
87 | } | |
88 | return true; | |
89 | } | |
90 | ||
91 | @Override | |
92 | public int compareTo(TraceValidationHelper o) { | |
93 | int retVal = fTraceToScan.compareTo(o.getTraceToScan()); | |
94 | if (retVal == 0) { | |
95 | retVal = fTraceType.compareTo(o.fTraceType); | |
96 | } | |
97 | return retVal; | |
98 | } | |
99 | } |