]> git.mxchange.org Git - jcontacts-business-core.git/blob - src/org/mxchange/jcontactsbusiness/model/jobposition/EmployeePosition.java
7c6e933d396f7282ff674541770c0f16dad952b5
[jcontacts-business-core.git] / src / org / mxchange / jcontactsbusiness / model / jobposition / EmployeePosition.java
1 /*
2  * Copyright (C) 2016 - 2018 Free Software Foundation
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.mxchange.jcontactsbusiness.model.jobposition;
18
19 import java.util.Date;
20 import java.util.Objects;
21 import javax.persistence.Basic;
22 import javax.persistence.Column;
23 import javax.persistence.Entity;
24 import javax.persistence.GeneratedValue;
25 import javax.persistence.GenerationType;
26 import javax.persistence.Id;
27 import javax.persistence.Table;
28 import javax.persistence.Temporal;
29 import javax.persistence.TemporalType;
30 import javax.persistence.Transient;
31 import org.mxchange.jcoreutils.Comparables;
32
33 /**
34  * A POJO for job positions
35  * <p>
36  * @author Roland Häder<roland@mxchange.org>
37  */
38 @Entity (name = "company_job_positions")
39 @Table (
40                 name = "company_job_positions"
41 )
42 @SuppressWarnings ("PersistenceUnitPresent")
43 public class EmployeePosition implements JobPosition {
44
45         /**
46          * Serial number
47          */
48         @Transient
49         private static final long serialVersionUID = 18_427_587_187_609L;
50
51         /**
52          * Timestamp when this entry has been created
53          */
54         @Basic (optional = false)
55         @Temporal (TemporalType.TIMESTAMP)
56         @Column (name = "job_position_created", nullable = false, updatable = false)
57         private Date jobPositionCreated;
58
59         /**
60          * Id number
61          */
62         @Id
63         @GeneratedValue (strategy = GenerationType.IDENTITY)
64         @Column (name = "job_position_id", nullable = false, updatable = false)
65         private Long jobPositionId;
66
67         /**
68          * Name/description of the job position (example: CEO)
69          */
70         @Basic (optional = false)
71         @Column (name = "job_position_name", nullable = false, unique = true)
72         private String jobPositionName;
73
74         /**
75          * Timestamp when this entry has been created
76          */
77         @Temporal (TemporalType.TIMESTAMP)
78         @Column (name = "job_position_updated", insertable = false)
79         private Date jobPositionUpdated;
80
81         @Override
82         public int compareTo (final JobPosition jobPosition) {
83                 // Check parameter on null-reference and equality to this
84                 if (null == jobPosition) {
85                         // Should not happen
86                         throw new NullPointerException("jobPosition is null"); //NOI18N
87                 } else if (jobPosition.equals(this)) {
88                         // Same object
89                         return 0;
90                 }
91
92                 // Init comparisons
93                 final int[] comparators = {
94                         // First position name ...
95                         this.getJobPositionName().compareToIgnoreCase(jobPosition.getJobPositionName())
96                 };
97
98                 // Check all values
99                 final int comparison = Comparables.checkAll(comparators);
100
101                 // Return value
102                 return comparison;
103         }
104
105         @Override
106         public boolean equals (final Object object) {
107                 if (this == object) {
108                         return true;
109                 } else if (null == object) {
110                         return false;
111                 } else if (this.getClass() != object.getClass()) {
112                         return false;
113                 }
114
115                 final JobPosition other = (JobPosition) object;
116
117                 if (!Objects.equals(this.getJobPositionId(), other.getJobPositionId())) {
118                         return false;
119                 } else if (!Objects.equals(this.getJobPositionName(), other.getJobPositionName())) {
120                         return false;
121                 }
122
123                 return true;
124         }
125
126         @Override
127         @SuppressWarnings ("ReturnOfDateField")
128         public Date getJobPositionCreated () {
129                 return this.jobPositionCreated;
130         }
131
132         @Override
133         @SuppressWarnings ("AssignmentToDateFieldFromParameter")
134         public void setJobPositionCreated (final Date jobPositionCreated) {
135                 this.jobPositionCreated = jobPositionCreated;
136         }
137
138         @Override
139         public Long getJobPositionId () {
140                 return this.jobPositionId;
141         }
142
143         @Override
144         public void setJobPositionId (final Long jobPositionId) {
145                 this.jobPositionId = jobPositionId;
146         }
147
148         @Override
149         public String getJobPositionName () {
150                 return this.jobPositionName;
151         }
152
153         @Override
154         public void setJobPositionName (final String jobPositionName) {
155                 this.jobPositionName = jobPositionName;
156         }
157
158         @Override
159         @SuppressWarnings ("ReturnOfDateField")
160         public Date getJobPositionUpdated () {
161                 return this.jobPositionUpdated;
162         }
163
164         @Override
165         @SuppressWarnings ("AssignmentToDateFieldFromParameter")
166         public void setJobPositionUpdated (final Date jobPositionUpdated) {
167                 this.jobPositionUpdated = jobPositionUpdated;
168         }
169
170         @Override
171         public int hashCode () {
172                 int hash = 7;
173
174                 hash = 37 * hash + Objects.hashCode(this.getJobPositionId());
175                 hash = 37 * hash + Objects.hashCode(this.getJobPositionName());
176
177                 return hash;
178         }
179
180 }