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
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.project.management;
\r
14 import java.util.regex.Matcher;
\r
17 * Graph bundle reference in graph.
\r
19 * @author Toni Kalajainen <toni.kalajainen@vtt.fi>
\r
21 public class GraphBundleRef {
\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
30 public static GraphBundleRef of(GraphBundle bundle) {
\r
31 return new GraphBundleRef(bundle.getId(), bundle.getMajor());
\r
34 public final String id;
\r
35 public final int major;
\r
37 public GraphBundleRef(String id, int major) {
\r
38 if (id==null) throw new IllegalArgumentException();
\r
44 public int hashCode() {
\r
45 return id.hashCode() + major;
\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
56 public String toString() {
\r
57 return id+"/"+major;
\r