Contribution for Bug352466: [TMF] Implement UML2 Sequence Diagram
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / views / uml2sd / util / SortSyncMessageComparator.java
1 /**********************************************************************
2 * Copyright (c) 2005, 2006 IBM Corporation and others.
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
7 * $Id: SortSyncMessageComparator.java,v 1.2 2006/09/20 20:56:27 ewchan Exp $
8 *
9 * Contributors:
10 * IBM - Initial API and implementation
11 * Bernd Hufmann - Updated for TMF
12 **********************************************************************/
13 package org.eclipse.linuxtools.tmf.ui.views.uml2sd.util;
14
15 import java.io.Serializable;
16 import java.util.Comparator;
17
18 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode;
19 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.SyncMessage;
20
21 /**
22 * Synchronous message comparator Compare two syncMessages only taking into account the event occurrence when their
23 * appear.<br>
24 *
25 * The message with the greater event occurrence is considered to be the greater.<br>
26 *
27 * @author sveyrier
28 *
29 */
30 public class SortSyncMessageComparator implements Comparator<GraphNode>, Serializable {
31
32 /**
33 * Serial version UID
34 */
35 private static final long serialVersionUID = 4781250984753283718L;
36
37 /**
38 * Compares two synchronous syncMessages. Returns 0 (equal) if one of the message is not synchronous
39 *
40 * @return 1 if arg0 is greater, 0 if equal, -1 otherwise
41 */
42 @Override
43 public int compare(GraphNode arg0, GraphNode arg1) {
44 if (arg0 instanceof SyncMessage && arg1 instanceof SyncMessage) {
45 SyncMessage m1 = (SyncMessage) arg0;
46 SyncMessage m2 = (SyncMessage) arg1;
47 if (m1.getEventOccurrence() > m2.getEventOccurrence())
48 return 1;
49 else if (m1.getEventOccurrence() == m2.getEventOccurrence())
50 return 0;
51 else
52 return -1;
53 } else
54 return 0;
55 }
56
57 }
This page took 0.03266 seconds and 6 git commands to generate.