1 /*******************************************************************************
2 * Copyright (c) 2010 Association for Decentralized Information Management in
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.databoard.accessor.reference;
19 public class IndexReference extends ChildReference {
23 public IndexReference(int index) { this.index = index; }
25 public IndexReference(int index, ChildReference child) {
31 public String toString(boolean labelReference) {
32 return labelReference ? ""+index : "i-"+index;
35 public int getIndex() {
39 public void setIndex(int index) {
44 public ChildReference clone() {
45 return new IndexReference(index, childReference==null ? null : childReference.clone());
49 public boolean equals(Object obj) {
50 if (obj instanceof IndexReference == false) return false;
51 IndexReference other = (IndexReference) obj;
52 if (other.index != index) return false;
53 if (other.hasChildReference() != hasChildReference()) return false;
54 if (hasChildReference() && !other.childReference.equals(childReference)) return false;
59 public int hashCode() {
60 int hash = 423423 + 37 * index;
61 if (hasChildReference()) hash = 31*hash + childReference.hashCode();