View Javadoc

1   /*
2    * Copyright 2006 Outsource Cafe, Inc.
3    *
4    * Licensed under the Apache License, Version 2.0 (the 'License')
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *    http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an 'AS IS' BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.javagen.agile.db.model;
17  
18  import javax.xml.bind.annotation.XmlAttribute;
19  import javax.xml.bind.annotation.XmlRootElement;
20  
21  import org.javagen.agile.core.model.Model;
22  
23  @XmlRootElement
24  public class PkColumn extends Column {
25  
26      public static final String DEFAULT_MODEL_TYPE = "COLUMN";
27  
28  	protected Short sequenceNumber;
29  	
30  	public PkColumn() {
31          super();
32          this.setModelType(DEFAULT_MODEL_TYPE);
33  	}
34  	
35      public PkColumn(Table parentTable) {
36          this();
37          this.setParentModel(parentTable);
38      }
39      
40      public PkColumn(String name) {
41          this();
42          this.setName(name);
43      }
44      
45      @Override
46      public boolean isKey() { return true; }
47      
48     @XmlAttribute
49  	public Short getSequenceNumber() {
50  		return sequenceNumber;
51  	}
52  	
53  	public void setSequenceNumber(Short sequenceNumber) {
54  		this.sequenceNumber = sequenceNumber;
55  	}
56  
57      @Override
58      public void copyTo(Model targetModel) {
59          PkColumn target = (PkColumn)targetModel;
60          super.copyTo(target);
61          if (this.getSequenceNumber()!=null)
62              target.setSequenceNumber(this.getSequenceNumber());
63      }
64  
65      @Override
66      public int hashCode() {
67          int result = super.hashCode();
68          result = 37*result + (this.sequenceNumber==null ? 0 : this.sequenceNumber.hashCode());
69          return result;
70      }
71      
72  }