Skip to content

Method: accept(GenClassVisitor)

1: package de.fhdw.wtf.generator.java.generatorModel;
2:
3: import java.util.Collection;
4: import java.util.Vector;
5:
6: import de.fhdw.wtf.generator.java.visitor.GenClassVisitor;
7: import de.fhdw.wtf.generator.java.visitor.GenClassVisitorException;
8: import de.fhdw.wtf.generator.java.visitor.GenClassVisitorReturn;
9:
10: /**
11: * A primitive class represents an already in wtf-sources existing class for a primitive/base type.
12: */
13: public abstract class GenPrimitiveClass extends GenClass {
14:         
15:         /**
16:          * The type this class is an instance of.
17:          */
18:         private final GenPrimitiveType instanceOf;
19:         /**
20:          * The operetions of the primitive class.
21:          */
22:         private static final Collection<GenJavaOperation> OPERATIONS = new Vector<>();
23:         /**
24:          * The interfaces the primitive class implements.
25:          */
26:         private static final Collection<GenInterfaceClass> IMPLEMENT = new Vector<>();
27:         /**
28:          * The package of the primitive class.
29:          */
30:         private static final GenPackage PACKAG = GenQualifiedPackage.create(
31:                         GenUnqualifiedPackage.create("de"),
32:                         GenQualifiedPackage.create(
33:                                         GenUnqualifiedPackage.create("fhdw"),
34:                                         GenQualifiedPackage.create(
35:                                                         GenUnqualifiedPackage.create("wtf"),
36:                                                         GenQualifiedPackage.create(
37:                                                                         GenUnqualifiedPackage.create("context"),
38:                                                                         GenUnqualifiedPackage.create("model")))));
39:         /**
40:          * The comment that describes the primitive class.
41:          */
42:         private static final GenComment COMMENT = GenComment.create("");
43:         /**
44:          * The additional code for primitive classes.
45:          */
46:         private static final String NON_GENERATED_PART = "";
47:         
48:         /**
49:          * Instantiates a new GenPrimitiveClass.
50:          *
51:          * @param instanceOf
52:          * The type this class is an instance of.
53:          */
54:         protected GenPrimitiveClass(final GenPrimitiveType instanceOf) {
55:                 super(instanceOf.getName(), OPERATIONS, IMPLEMENT, PACKAG, COMMENT, NON_GENERATED_PART);
56:                 this.instanceOf = instanceOf;
57:         }
58:         
59:         /**
60:          * Returns the type this class is an instance of.
61:          *
62:          * @return GenPrimitiveType
63:          */
64:         public GenPrimitiveType getType() {
65:                 return this.instanceOf;
66:         }
67:         
68:         @Override
69:         public void accept(final GenClassVisitor visitor) {
70:                 visitor.handle(this);
71:         }
72:         
73:         @Override
74:         public <X> X accept(final GenClassVisitorReturn<X> visitor) {
75:                 return visitor.handle(this);
76:         }
77:         
78:         @Override
79:         public <X extends Exception> void accept(final GenClassVisitorException<X> visitor) throws X {
80:                 visitor.handle(this);
81:         }
82:         
83: }