01: package org.andromda.translation.ocl.syntax;
02:
03: import org.andromda.core.common.ExceptionUtils;
04: import org.apache.commons.lang.StringUtils;
05:
06: /**
07: * An implementation of the ocl OperationDeclaration facade.
08: *
09: * @author Chad Brandon
10: * @see org.andromda.translation.ocl.syntax.OperationDeclaration
11: */
12: public class OperationDeclarationImpl implements OperationDeclaration {
13:
14: private String name;
15: private String returnType;
16: private VariableDeclaration[] arguments = new VariableDeclaration[0];
17:
18: /**
19: * Constructs a new OperationDeclarationImpl
20: *
21: * @param name the name of the Operation
22: * @param returnType the returnType of the operation
23: * @param arguments the arguments of the operation.
24: */
25: public OperationDeclarationImpl(String name, String returnType,
26: VariableDeclaration[] arguments) {
27: ExceptionUtils.checkEmpty("name", name);
28: this .name = StringUtils.trimToEmpty(name);
29: this .returnType = StringUtils.trimToEmpty(returnType);
30: this .arguments = arguments;
31: }
32:
33: /**
34: * @see org.andromda.translation.ocl.syntax.OperationDeclaration#getName()
35: */
36: public String getName() {
37: return this .name;
38: }
39:
40: /**
41: * @see org.andromda.translation.ocl.syntax.OperationDeclaration#getReturnType()
42: */
43: public String getReturnType() {
44: return this .returnType;
45: }
46:
47: /**
48: * @see org.andromda.translation.ocl.syntax.OperationDeclaration#getArguments()
49: */
50: public VariableDeclaration[] getArguments() {
51: return arguments;
52: }
53:
54: /**
55: * @see java.lang.Object#toString()
56: */
57: public String toString() {
58: StringBuffer toString = new StringBuffer(this .getName());
59: toString.append("(");
60: if (this .getArguments().length > 0) {
61: toString.append(StringUtils.join(this .getArguments(), ','));
62: }
63: toString.append(")");
64: if (StringUtils.isNotEmpty(this .getReturnType())) {
65: toString.append("::");
66: toString.append(this.getReturnType());
67: }
68: return toString.toString();
69: }
70:
71: }
|