Skip to content

Package: ConstructorOrOperation

ConstructorOrOperation

nameinstructionbranchcomplexitylinemethod
ConstructorOrOperation(String, ProductType, ClassType, Type, Token, Token)
M: 0 C: 14
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
getContainingType()
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getName()
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getParameters()
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getReturnType()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getSignature()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%

Coverage

1: package de.fhdw.wtf.common.ast;
2:
3: import de.fhdw.wtf.common.ast.type.ClassType;
4: import de.fhdw.wtf.common.ast.type.ProductType;
5: import de.fhdw.wtf.common.ast.type.Type;
6: import de.fhdw.wtf.common.ast.visitor.ConstructorOrOperationExceptionVisitor;
7: import de.fhdw.wtf.common.exception.walker.TaskException;
8: import de.fhdw.wtf.common.token.Token;
9:
10: /**
11: * This abstract class represents constructors or operations of a class.
12: */
13: public abstract class ConstructorOrOperation extends SyntaxObject {
14:         
15:         /**
16:          * Represents {@link Type} which will be returned by this constructor or operation.
17:          */
18:         private final Type returnType;
19:         
20:         /**
21:          * @return Represents the type which includes the {@link ConstructorOrOperation}
22:          */
23:         public Type getReturnType() {
24:                 return this.returnType;
25:         }
26:         
27:         private final ConstructorOrOperationSignature signature;
28:         
29:         /**
30:          * Creates a new {@link ConstructorOrOperation}.
31:          *
32:          * @param parameters
33:          * The parameters of the constructor or operation.
34:          * @param containingType
35:          * containingType of the Constructor or Operation
36:          * @param returnType
37:          * @param firstToken
38:          * firstToken.
39:          * @param lastToken
40:          * lastToken.
41:          */
42:         protected ConstructorOrOperation(final String name,
43:                         final ProductType parameters,
44:                         final ClassType containingType,
45:                         final Type returnType,
46:                         final Token firstToken,
47:                         final Token lastToken) {
48:                 super(firstToken, lastToken);
49:                 this.signature = ConstructorOrOperationSignature.create(name, parameters, containingType);
50:                 this.returnType = returnType;
51:         }
52:         
53:         /**
54:          * @return Returns the signature of this {@link ConstructorOrOperation}
55:          */
56:         public ConstructorOrOperationSignature getSignature() {
57:                 return this.signature;
58:         }
59:         
60:         @Override
61:         public abstract boolean equals(final Object o);
62:         
63:         @Override
64:         public abstract int hashCode();
65:         
66:         @Override
67:         public abstract String toString();
68:         
69:         /**
70:          * Same as getSignature().getParameter()
71:          *
72:          * @return the parameter which is assigned to this {@link ConstructorOrOperation}
73:          */
74:         public ProductType getParameters() {
75:                 return this.signature.getParameters();
76:         }
77:         
78:         /**
79:          * Same as getSignature().getName()
80:          *
81:          * @return the name of this {@link ConstructorOrOperation}
82:          */
83:         public String getName() {
84:                 return this.signature.getName();
85:         }
86:         
87:         /**
88:          * Same as getSignature().getContainingType()
89:          *
90:          * @return the containingType which is assigned to this {@link ConstructorOrOperation}
91:          */
92:         public ClassType getContainingType() {
93:                 return this.signature.getContainingType();
94:         }
95:         
96:         /**
97:          * @param constructorAndOperationVisitor
98:          * @throws TaskException
99:          */
100:         public abstract void accept(final ConstructorOrOperationExceptionVisitor<TaskException> constructorAndOperationVisitor)
101:                         throws TaskException;
102: }