1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2011 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.util;
\r
14 import org.simantics.databoard.type.ArrayType;
\r
15 import org.simantics.databoard.type.BooleanType;
\r
16 import org.simantics.databoard.type.ByteType;
\r
17 import org.simantics.databoard.type.Datatype;
\r
18 import org.simantics.databoard.type.DoubleType;
\r
19 import org.simantics.databoard.type.FloatType;
\r
20 import org.simantics.databoard.type.IntegerType;
\r
21 import org.simantics.databoard.type.LongType;
\r
22 import org.simantics.databoard.type.MapType;
\r
23 import org.simantics.databoard.type.OptionalType;
\r
24 import org.simantics.databoard.type.RecordType;
\r
25 import org.simantics.databoard.type.StringType;
\r
26 import org.simantics.databoard.type.UnionType;
\r
27 import org.simantics.databoard.type.VariantType;
\r
29 public class DatatypeVisitorAdapter implements Datatype.Visitor1 {
\r
31 protected IdentityHashSet<Datatype> visited = new IdentityHashSet<Datatype>();
\r
34 public void visit(ArrayType b, Object obj) {
\r
35 if ( !visited.add(b) ) return;
\r
36 b.componentType.accept(this, obj);
\r
40 public void visit(BooleanType b, Object obj) {
\r
44 public void visit(DoubleType b, Object obj) {
\r
48 public void visit(FloatType b, Object obj) {
\r
52 public void visit(IntegerType b, Object obj) {
\r
56 public void visit(ByteType b, Object obj) {
\r
60 public void visit(LongType b, Object obj) {
\r
64 public void visit(OptionalType b, Object obj) {
\r
65 if ( !visited.add(b) ) return;
\r
66 b.componentType.accept(this, obj);
\r
70 public void visit(RecordType b, Object obj) {
\r
71 if ( !visited.add(b) ) return;
\r
72 for (int i=0; i<b.getComponentCount(); i++)
\r
73 b.getComponent(i).type.accept(this, obj);
\r
77 public void visit(StringType b, Object obj) {
\r
81 public void visit(UnionType b, Object obj) {
\r
82 if ( !visited.add(b) ) return;
\r
83 for (int i=0; i<b.getComponentCount(); i++)
\r
84 b.getComponent(i).type.accept(this, obj);
\r
88 public void visit(VariantType b, Object obj) {
\r
92 public void visit(MapType b, Object obj) {
\r
93 if ( !visited.add(b) ) return;
\r
94 b.keyType.accept(this, obj);
\r
95 b.valueType.accept(this, obj);
\r