Java Doc and API clean up of TMF UML Sequence diagram framework
[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 * Copyright (c) 2011, 2012 Ericsson.
4 *
5 * All rights reserved. This program and the accompanying materials
6 * are made available under the terms of the Eclipse Public License v1.0
7 * which accompanies this distribution, and is available at
8 * http://www.eclipse.org/legal/epl-v10.html
9 *
10 * Contributors:
11 * IBM - Initial API and implementation
12 * Bernd Hufmann - Updated for TMF
13 **********************************************************************/
14 package org.eclipse.linuxtools.tmf.ui.views.uml2sd.util;
15
16 import java.io.Serializable;
17 import java.util.Comparator;
18
19 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode;
20 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.SyncMessage;
21
22 /**
23 * Synchronous message comparator Compare two syncMessages only taking into account the event occurrence when their
24 * appear.<br>
25 *
26 * The message with the greater event occurrence is considered to be the greater.<br>
27 *
28 * @author sveyrier
29 *
30 */
31 public class SortSyncMessageComparator implements Comparator<GraphNode>, Serializable {
32
33 // ------------------------------------------------------------------------
34 // Constants
35 // ------------------------------------------------------------------------
36 /**
37 * Serial version UID
38 */
39 private static final long serialVersionUID = 4781250984753283718L;
40
41 // ------------------------------------------------------------------------
42 // Methods
43 // ------------------------------------------------------------------------
44 /*
45 * (non-Javadoc)
46 * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
47 */
48 @Override
49 public int compare(GraphNode arg0, GraphNode arg1) {
50 if (arg0 instanceof SyncMessage && arg1 instanceof SyncMessage) {
51 SyncMessage m1 = (SyncMessage) arg0;
52 SyncMessage m2 = (SyncMessage) arg1;
53 if (m1.getEventOccurrence() > m2.getEventOccurrence()) {
54 return 1;
55 } else if (m1.getEventOccurrence() == m2.getEventOccurrence()) {
56 return 0;
57 } else {
58 return -1;
59 }
60 } else {
61 return 0;
62 }
63 }
64 }
This page took 0.031266 seconds and 5 git commands to generate.