--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.databoard.util;\r
+\r
+import org.simantics.databoard.type.ArrayType;\r
+import org.simantics.databoard.type.BooleanType;\r
+import org.simantics.databoard.type.ByteType;\r
+import org.simantics.databoard.type.Datatype;\r
+import org.simantics.databoard.type.DoubleType;\r
+import org.simantics.databoard.type.FloatType;\r
+import org.simantics.databoard.type.IntegerType;\r
+import org.simantics.databoard.type.LongType;\r
+import org.simantics.databoard.type.MapType;\r
+import org.simantics.databoard.type.OptionalType;\r
+import org.simantics.databoard.type.RecordType;\r
+import org.simantics.databoard.type.StringType;\r
+import org.simantics.databoard.type.UnionType;\r
+import org.simantics.databoard.type.VariantType;\r
+\r
+public class DatatypeVisitorAdapter implements Datatype.Visitor1 {\r
+\r
+ protected IdentityHashSet<Datatype> visited = new IdentityHashSet<Datatype>();\r
+\r
+ @Override\r
+ public void visit(ArrayType b, Object obj) {\r
+ if ( !visited.add(b) ) return; \r
+ b.componentType.accept(this, obj);\r
+ }\r
+\r
+ @Override\r
+ public void visit(BooleanType b, Object obj) {\r
+ }\r
+\r
+ @Override\r
+ public void visit(DoubleType b, Object obj) {\r
+ }\r
+\r
+ @Override\r
+ public void visit(FloatType b, Object obj) {\r
+ }\r
+\r
+ @Override\r
+ public void visit(IntegerType b, Object obj) {\r
+ }\r
+\r
+ @Override\r
+ public void visit(ByteType b, Object obj) {\r
+ }\r
+\r
+ @Override\r
+ public void visit(LongType b, Object obj) {\r
+ }\r
+\r
+ @Override\r
+ public void visit(OptionalType b, Object obj) {\r
+ if ( !visited.add(b) ) return; \r
+ b.componentType.accept(this, obj);\r
+ }\r
+\r
+ @Override\r
+ public void visit(RecordType b, Object obj) {\r
+ if ( !visited.add(b) ) return; \r
+ for (int i=0; i<b.getComponentCount(); i++)\r
+ b.getComponent(i).type.accept(this, obj);\r
+ }\r
+\r
+ @Override\r
+ public void visit(StringType b, Object obj) {\r
+ }\r
+\r
+ @Override\r
+ public void visit(UnionType b, Object obj) {\r
+ if ( !visited.add(b) ) return; \r
+ for (int i=0; i<b.getComponentCount(); i++)\r
+ b.getComponent(i).type.accept(this, obj);\r
+ }\r
+\r
+ @Override\r
+ public void visit(VariantType b, Object obj) {\r
+ }\r
+\r
+ @Override\r
+ public void visit(MapType b, Object obj) {\r
+ if ( !visited.add(b) ) return; \r
+ b.keyType.accept(this, obj);\r
+ b.valueType.accept(this, obj);\r
+ }\r
+\r
+\r
+}\r