analysis: Move plugins to their own sub-directory
[deliverable/tracecompass.git] / org.eclipse.tracecompass.tmf.ui / src / org / eclipse / tracecompass / tmf / ui / views / uml2sd / util / SortSyncMessageComparator.java
CommitLineData
73005152 1/**********************************************************************
ed902a2b 2 * Copyright (c) 2005, 2014 IBM Corporation, Ericsson
73005152
BH
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
013a5f1c
AM
7 *
8 * Contributors:
c8422608
AM
9 * IBM - Initial API and implementation
10 * Bernd Hufmann - Updated for TMF
73005152 11 **********************************************************************/
c8422608 12
2bdf0193 13package org.eclipse.tracecompass.tmf.ui.views.uml2sd.util;
73005152
BH
14
15import java.io.Serializable;
16import java.util.Comparator;
17
2bdf0193
AM
18import org.eclipse.tracecompass.tmf.ui.views.uml2sd.core.GraphNode;
19import org.eclipse.tracecompass.tmf.ui.views.uml2sd.core.SyncMessage;
73005152
BH
20
21/**
22 * Synchronous message comparator Compare two syncMessages only taking into account the event occurrence when their
23 * appear.<br>
013a5f1c 24 *
73005152 25 * The message with the greater event occurrence is considered to be the greater.<br>
013a5f1c
AM
26 *
27 * @version 1.0
73005152 28 * @author sveyrier
013a5f1c 29 *
73005152
BH
30 */
31public class SortSyncMessageComparator implements Comparator<GraphNode>, Serializable {
32
df0b8ff4
BH
33 // ------------------------------------------------------------------------
34 // Constants
35 // ------------------------------------------------------------------------
11252342 36
73005152
BH
37 /**
38 * Serial version UID
39 */
40 private static final long serialVersionUID = 4781250984753283718L;
41
df0b8ff4
BH
42 // ------------------------------------------------------------------------
43 // Methods
44 // ------------------------------------------------------------------------
11252342 45
73005152
BH
46 @Override
47 public int compare(GraphNode arg0, GraphNode arg1) {
48 if (arg0 instanceof SyncMessage && arg1 instanceof SyncMessage) {
49 SyncMessage m1 = (SyncMessage) arg0;
50 SyncMessage m2 = (SyncMessage) arg1;
df0b8ff4 51 if (m1.getEventOccurrence() > m2.getEventOccurrence()) {
73005152 52 return 1;
df0b8ff4 53 } else if (m1.getEventOccurrence() == m2.getEventOccurrence()) {
73005152 54 return 0;
df0b8ff4 55 } else {
73005152 56 return -1;
df0b8ff4 57 }
df0b8ff4 58 }
abbdd66a 59 return 0;
73005152 60 }
73005152 61}
This page took 0.079978 seconds and 5 git commands to generate.