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