1 package org.andromda.translation.ocl.syntax;
2
3 import org.andromda.core.common.ExceptionUtils;
4 import org.apache.commons.lang.StringUtils;
5
6
7
8
9
10
11
12 public class OperationDeclarationImpl
13 implements OperationDeclaration
14 {
15 private String name;
16 private String returnType;
17 private VariableDeclaration[] arguments = new VariableDeclaration[0];
18
19
20
21
22
23
24
25
26 public OperationDeclarationImpl(String name, String returnType, VariableDeclaration[] arguments)
27 {
28 ExceptionUtils.checkEmpty("name", name);
29 this.name = StringUtils.trimToEmpty(name);
30 this.returnType = StringUtils.trimToEmpty(returnType);
31 this.arguments = arguments;
32 }
33
34
35
36
37 public String getName()
38 {
39 return this.name;
40 }
41
42
43
44
45 public String getReturnType()
46 {
47 return this.returnType;
48 }
49
50
51
52
53 public VariableDeclaration[] getArguments()
54 {
55 return arguments;
56 }
57
58
59
60
61 public String toString()
62 {
63 StringBuilder toString = new StringBuilder(this.getName());
64 toString.append('(');
65 if (this.getArguments().length > 0)
66 {
67 toString.append(StringUtils.join(this.getArguments(), ','));
68 }
69 toString.append(')');
70 if (StringUtils.isNotBlank(this.getReturnType()))
71 {
72 toString.append("::");
73 toString.append(this.getReturnType());
74 }
75 return toString.toString();
76 }
77
78 }