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