1 /*******************************************************************************
\r
2 * Copyright (c) 2010 Association for Decentralized Information Management in
\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.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) {
\r
32 return labelReference ? ""+index : "i-"+index;
\r
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) {
\r
50 if (obj instanceof IndexReference == false) return false;
\r
51 IndexReference other = (IndexReference) obj;
\r
52 if (other.index != index) return false;
\r
53 if (other.hasChildReference() != hasChildReference()) return false;
\r
54 if (hasChildReference() && !other.childReference.equals(childReference)) return false;
\r
59 public int hashCode() {
\r
60 int hash = 423423 + 37 * index;
\r
61 if (hasChildReference()) hash = 31*hash + childReference.hashCode();
\r