1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.project.management;
14 import java.util.regex.Matcher;
17 * Graph bundle reference in graph.
19 * @author Toni Kalajainen <toni.kalajainen@vtt.fi>
21 public class GraphBundleRef {
23 public static GraphBundleRef of(String versionedId) {
24 Matcher m = GraphBundle.VERSIONED_ID_PATTERN.matcher(versionedId);
25 String id = m.group(1);
26 int major = Integer.valueOf( m.group(2) );
27 return new GraphBundleRef(id, major);
30 public static GraphBundleRef of(GraphBundle bundle) {
31 return new GraphBundleRef(bundle.getId(), bundle.getMajor());
34 public final String id;
35 public final int major;
37 public GraphBundleRef(String id, int major) {
38 if (id==null) throw new IllegalArgumentException();
44 public int hashCode() {
45 return id.hashCode() + major;
49 public boolean equals(Object obj) {
50 if (obj instanceof GraphBundleRef == false) return false;
51 GraphBundleRef other = (GraphBundleRef) obj;
52 return other.id.equals(id) && other.major == major;
56 public String toString() {