]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.databoard/src/org/simantics/databoard/util/DatatypeVisitorAdapter.java
Added addFirst/After/Before + remove SCL functions for Ordered Sets
[simantics/platform.git] / bundles / org.simantics.databoard / src / org / simantics / databoard / util / DatatypeVisitorAdapter.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2011 Association for Decentralized Information Management in
3  * Industry THTH ry.
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
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.databoard.util;
13
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;
28
29 public class DatatypeVisitorAdapter implements Datatype.Visitor1 {
30
31         protected IdentityHashSet<Datatype> visited = new IdentityHashSet<Datatype>();
32
33         @Override
34         public void visit(ArrayType b, Object obj) {
35                 if ( !visited.add(b) ) return; 
36                 b.componentType.accept(this, obj);
37         }
38
39         @Override
40         public void visit(BooleanType b, Object obj) {
41         }
42
43         @Override
44         public void visit(DoubleType b, Object obj) {
45         }
46
47         @Override
48         public void visit(FloatType b, Object obj) {
49         }
50
51         @Override
52         public void visit(IntegerType b, Object obj) {
53         }
54
55         @Override
56         public void visit(ByteType b, Object obj) {
57         }
58
59         @Override
60         public void visit(LongType b, Object obj) {
61         }
62
63         @Override
64         public void visit(OptionalType b, Object obj) {
65                 if ( !visited.add(b) ) return; 
66                 b.componentType.accept(this, obj);
67         }
68
69         @Override
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);
74         }
75
76         @Override
77         public void visit(StringType b, Object obj) {
78         }
79
80         @Override
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);
85         }
86
87         @Override
88         public void visit(VariantType b, Object obj) {
89         }
90
91         @Override
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);
96         }
97
98
99 }