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 VariableDeclaration.
08: *
09: * @author Chad Brandon
10: * @see org.andromda.translation.ocl.syntax.VariableDeclaration
11: */
12: public class VariableDeclarationImpl implements VariableDeclaration {
13:
14: private String name;
15: private String type;
16: private String value;
17:
18: /**
19: * Constructs a new VariableDeclarationImpl
20: *
21: * @param name the name of the VariableDeclaratiom
22: * @param type the type of the VariableDeclaration
23: */
24: public VariableDeclarationImpl(String name, String type,
25: String value) {
26: ExceptionUtils.checkNull("name", name);
27: this .name = StringUtils.trimToEmpty(name);
28: this .type = StringUtils.trimToEmpty(type);
29: this .value = StringUtils.trimToEmpty(value);
30: }
31:
32: /**
33: * @see org.andromda.translation.ocl.syntax.VariableDeclaration#getName()
34: */
35: public String getName() {
36: return this .name;
37: }
38:
39: /**
40: * ==
41: *
42: * @see org.andromda.translation.ocl.syntax.VariableDeclaration#getType()
43: */
44: public String getType() {
45: return this .type;
46: }
47:
48: /**
49: * @see org.andromda.translation.ocl.syntax.VariableDeclaration#getValue()
50: */
51: public String getValue() {
52: return this .value;
53: }
54:
55: /**
56: * @see java.lang.Object#toString()
57: */
58: public String toString() {
59: StringBuffer toString = new StringBuffer(this .getName());
60: if (StringUtils.isNotEmpty(this .getType())) {
61: toString.append(":");
62: toString.append(this.getType());
63: }
64: return toString.toString();
65: }
66:
67: }
|