-
Notifications
You must be signed in to change notification settings - Fork 10
/
TmfEdgeLegacyWrapper.java
114 lines (97 loc) · 3.3 KB
/
TmfEdgeLegacyWrapper.java
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/*******************************************************************************
* Copyright (c) 2022, 2024 École Polytechnique de Montréal and others
*
* All rights reserved. This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0 which
* accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
package org.eclipse.tracecompass.internal.analysis.graph.core.graph.legacy;
import java.util.Objects;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.tracecompass.analysis.graph.core.graph.ITmfEdge;
import org.eclipse.tracecompass.analysis.graph.core.graph.ITmfVertex;
import org.eclipse.tracecompass.internal.analysis.graph.core.base.TmfEdge;
/**
* Wrapper around the legacy {@link TmfEdge} class to make it an ITmfEdge
*
* @author Geneviève Bastien
*/
public class TmfEdgeLegacyWrapper implements ITmfEdge {
private TmfEdge fLegacyEdge;
private TmfVertexLegacyWrapper fFrom;
private TmfVertexLegacyWrapper fTo;
/**
* Convert the new edge type enum values to the legacy API
*
* @param contextState
* The edge type from the new API
* @return The edge type from the legacy API
*/
public static TmfEdge.EdgeType newTypeToOldType(OSEdgeContextState contextState) {
return contextState.getOldEdgeType();
}
/**
* Convert the legacy API edge type enum values to the new API
*
* @param type
* The edge type from the legacy API
* @return The edge type from the new API
*/
public static OSEdgeContextState oldTypeToNewType(TmfEdge.EdgeType type) {
return new OSEdgeContextState(type);
}
/**
* Constructor
*
* @param edge
* The edge to wrap in this class
* @param from
* The new vertex this edge is from
* @param to
* The new vertex this edge goes to
*/
public TmfEdgeLegacyWrapper(TmfEdge edge, TmfVertexLegacyWrapper from, TmfVertexLegacyWrapper to) {
fLegacyEdge = edge;
fFrom = from;
fTo = to;
}
@Override
public ITmfVertex getVertexFrom() {
return fFrom;
}
@Override
public ITmfVertex getVertexTo() {
return fTo;
}
@Override
public OSEdgeContextState getEdgeContextState() {
return oldTypeToNewType(fLegacyEdge.getType());
}
@Override
public @Nullable String getLinkQualifier() {
return fLegacyEdge.getLinkQualifier();
}
@Override
public long getDuration() {
return fLegacyEdge.getDuration();
}
@Override
public boolean equals(@Nullable Object obj) {
if (!(obj instanceof TmfEdgeLegacyWrapper)) {
return false;
}
TmfEdgeLegacyWrapper other = (TmfEdgeLegacyWrapper) obj;
return Objects.equals(fLegacyEdge, other.fLegacyEdge) && Objects.equals(fFrom, other.fFrom) && Objects.equals(fTo, other.fTo);
}
@Override
public int hashCode() {
return Objects.hash(fLegacyEdge, fTo, fFrom);
}
@Override
public String toString() {
return "[Legacy edge: " + fLegacyEdge + ']'; //$NON-NLS-1$
}
}