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.type;
14 import java.util.Set;
\r
16 import org.simantics.databoard.accessor.error.ReferenceException;
\r
17 import org.simantics.databoard.accessor.reference.ChildReference;
\r
18 import org.simantics.databoard.util.IdentityPair;
\r
20 public class VariantType extends Datatype {
22 public VariantType() {
26 public int getComponentCount() {
\r
31 public Datatype getComponentType(int index) {
\r
32 throw new IllegalArgumentException();
\r
36 public Datatype getComponentType(ChildReference path) {
\r
37 if (path==null) return this;
\r
38 throw new IllegalArgumentException();
\r
42 protected boolean deepEquals(Object obj, Set<IdentityPair<Datatype, Datatype>> compareHistory) {
43 if (this==obj) return true;
\r
44 if ( !hasEqualMetadata(obj) ) return false;
\r
45 return obj instanceof VariantType;
49 public int hashCode() {
50 return 192837465 + super.hashCode();
54 public <T> T accept(Visitor<T> v) {
59 public void accept(Visitor1 v, Object obj) {
63 @SuppressWarnings("unchecked")
\r
65 public <T extends Datatype> T getChildType(ChildReference reference) throws ReferenceException {
\r
66 if (reference==null) return (T) this;
\r
67 throw new ReferenceException("Cannot get variant type without instance");
\r