]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.project/src/org/simantics/project/management/GraphBundleRef.java
Include acorn db in db.client feature and make it the default db driver
[simantics/platform.git] / bundles / org.simantics.project / src / org / simantics / project / management / GraphBundleRef.java
1 /*******************************************************************************\r
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
3  * in Industry THTH ry.\r
4  * All rights reserved. This program and the accompanying materials\r
5  * are made available under the terms of the Eclipse Public License v1.0\r
6  * which accompanies this distribution, and is available at\r
7  * http://www.eclipse.org/legal/epl-v10.html\r
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.project.management;\r
13 \r
14 import java.util.regex.Matcher;\r
15 \r
16 /**\r
17  * Graph bundle reference in graph.\r
18  *\r
19  * @author Toni Kalajainen <toni.kalajainen@vtt.fi>\r
20  */\r
21 public class GraphBundleRef {\r
22 \r
23         public static GraphBundleRef of(String versionedId) {\r
24                 Matcher m = GraphBundle.VERSIONED_ID_PATTERN.matcher(versionedId);\r
25                 String id = m.group(1);\r
26                 int major = Integer.valueOf( m.group(2) );\r
27                 return new GraphBundleRef(id, major);\r
28         }\r
29         \r
30         public static GraphBundleRef of(GraphBundle bundle) {\r
31                 return new GraphBundleRef(bundle.getId(), bundle.getMajor());\r
32         }\r
33         \r
34         public final String id;\r
35         public final int major;\r
36         \r
37         public GraphBundleRef(String id, int major) {\r
38                 if (id==null) throw new IllegalArgumentException();\r
39                 this.id = id;\r
40                 this.major = major;\r
41         }\r
42         \r
43         @Override\r
44         public int hashCode() {\r
45                 return id.hashCode() + major;\r
46         }\r
47         \r
48         @Override\r
49         public boolean equals(Object obj) {\r
50                 if (obj instanceof GraphBundleRef == false) return false;\r
51                 GraphBundleRef other = (GraphBundleRef) obj;\r
52                 return other.id.equals(id) && other.major == major;\r
53         }\r
54         \r
55         @Override\r
56         public String toString() {\r
57                 return id+"/"+major;\r
58         }\r
59         \r
60 }\r
61 \r