View Javadoc
1   /*
2    * Copyright (C) 2016 uwe
3    *
4    * This program is free software: you can redistribute it and/or modify
5    * it under the terms of the GNU General Public License as published by
6    * the Free Software Foundation, either version 3 of the License, or
7    * (at your option) any later version.
8    *
9    * This program is distributed in the hope that it will be useful,
10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12   * GNU General Public License for more details.
13   *
14   * You should have received a copy of the GNU General Public License
15   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16   */
17  package org.sw4j.tool.annotation.jpa.generator.model;
18  
19  import javax.annotation.Nonnull;
20  import javax.xml.bind.annotation.XmlAccessType;
21  import javax.xml.bind.annotation.XmlAccessorType;
22  import javax.xml.bind.annotation.XmlAttribute;
23  
24  /**
25   * This class represents an attribute. Via the attribute you can access the columns assigned to the attribute.
26   *
27   * @author Uwe Plonus
28   */
29  @XmlAccessorType(XmlAccessType.NONE)
30  public class Attribute {
31  
32      /** The name of the attribute. */
33      private final String name;
34  
35      /** Flag to indicate this attribute as Id. */
36      private final boolean isId;
37  
38      /** The Java datatype of this attribute. */
39      private final String dataType;
40  
41      /**
42       * Constructor for an attribute.
43       *
44       * @param name the name of the attribute.
45       * @param isId if this attribute should be marked as Id.
46       * @param dataType the Java datatype of the attribute
47       */
48      public Attribute(@Nonnull final String name, final boolean isId, @Nonnull final String dataType) {
49          this.name = name;
50          this.isId = isId;
51          this.dataType = dataType;
52      }
53  
54      /**
55       * Returns the name of the attribute.
56       *
57       * @return the name.
58       */
59      @Nonnull
60      @XmlAttribute(name = "name")
61      public String getName() {
62          return this.name;
63      }
64  
65      /**
66       * Returns if this attribute is an Id.
67       *
68       * @return {@code true} if this attribute is an Id.
69       */
70      @XmlAttribute(name = "isId")
71      public boolean isId() {
72          return this.isId;
73      }
74  
75      /**
76       * Returns the java data type of this attribute.
77       *
78       * @return the data type of this attribute.
79       */
80      @Nonnull
81      @XmlAttribute(name = "dataType")
82      public String getDataType() {
83          return this.dataType;
84      }
85  
86  }