]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.modeling/src/org/simantics/modeling/subscription/SubscriptionItem.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.modeling / src / org / simantics / modeling / subscription / SubscriptionItem.java
1 /*******************************************************************************\r
2  * Copyright (c) 2007 VTT Technical Research Centre of Finland and others.\r
3  * All rights reserved. This program and the accompanying materials\r
4  * are made available under the terms of the Eclipse Public License v1.0\r
5  * which accompanies this distribution, and is available at\r
6  * http://www.eclipse.org/legal/epl-v10.html\r
7  *\r
8  * Contributors:\r
9  *     VTT Technical Research Centre of Finland - initial API and implementation\r
10  *******************************************************************************/\r
11 package org.simantics.modeling.subscription;\r
12 \r
13 import org.simantics.databoard.annotations.Identifier;\r
14 import org.simantics.databoard.annotations.Optional;\r
15 import org.simantics.databoard.util.Bean;\r
16 import org.simantics.utils.strings.AlphanumComparator;\r
17 \r
18 /**\r
19  * @author Antti Villberg\r
20  */\r
21 public class SubscriptionItem extends Bean {\r
22         \r
23         // Normal Label (eg. The label in CSV file)\r
24         public @Optional String simpleLabel;\r
25         // Variable reference in user friendly format\r
26         public @Optional String variableReference;\r
27         \r
28         // GroupId in the history\r
29         public @Identifier String groupId;\r
30         // ItemId in the group\r
31         public @Identifier String groupItemId;\r
32         // Variable id in format understood by org.simantics.simulation.data.Datasource\r
33         public @Identifier String variableId;\r
34         \r
35         public @Optional String unit;\r
36         \r
37         public SubscriptionItem() {\r
38         }\r
39         \r
40         @Override\r
41         public int compareTo(Bean o) {\r
42                 if ( o instanceof SubscriptionItem == false ) return 0;\r
43                 SubscriptionItem other = (SubscriptionItem) o;\r
44                 \r
45                 String myLabel2 = simpleLabel!=null?simpleLabel:"";\r
46                 String otLabel2 = other.simpleLabel!=null?other.simpleLabel:"";\r
47                 int c = AlphanumComparator.CASE_INSENSITIVE_COMPARATOR.compare(myLabel2, otLabel2);\r
48                 if ( c!=0 ) return c;\r
49                 \r
50                 String mySid = groupId!=null?groupId:""; \r
51                 String otSid = other.groupId!=null?other.groupId:""; \r
52                 c = mySid.compareTo(otSid);\r
53                 if ( c!=0 ) return c;\r
54 \r
55                 String myGiid = groupItemId!=null?groupItemId:""; \r
56                 String otGiid = other.groupItemId!=null?other.groupItemId:""; \r
57                 c = myGiid.compareTo(otGiid);\r
58                 if ( c!=0 ) return c;\r
59 \r
60                 String myVid = variableId!=null?variableId:""; \r
61                 String otVid = other.variableId!=null?other.variableId:""; \r
62                 c = myVid.compareTo(otVid);\r
63                 if ( c!=0 ) return c;\r
64                 \r
65                 return c;               \r
66         }\r
67         \r
68 }\r
69 \r