]> git.mxchange.org Git - jcontacts-business-core.git/blob - src/org/mxchange/jcontactsbusiness/opening_times/BusinessOpeningTimes.java
surpressed warnings that cannot be fixed anyway
[jcontacts-business-core.git] / src / org / mxchange / jcontactsbusiness / opening_times / BusinessOpeningTimes.java
1 /*
2  * Copyright (C) 2016 Roland Haeder
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.opening_times;
18
19 import java.time.DayOfWeek;
20 import java.util.Calendar;
21 import java.util.Objects;
22 import javax.persistence.Basic;
23 import javax.persistence.Column;
24 import javax.persistence.Entity;
25 import javax.persistence.EnumType;
26 import javax.persistence.Enumerated;
27 import javax.persistence.GeneratedValue;
28 import javax.persistence.GenerationType;
29 import javax.persistence.Id;
30 import javax.persistence.Table;
31 import javax.persistence.Temporal;
32 import javax.persistence.TemporalType;
33
34 /**
35  * A POJO for business opening hours
36  * <p>
37  * @author Roland Haeder<roland@mxchange.org>
38  */
39 @Entity (name = "company_opening_times")
40 @Table (name = "company_opening_times")
41 @SuppressWarnings ("PersistenceUnitPresent")
42 public class BusinessOpeningTimes implements OpeningTimes {
43
44         /**
45          * Serial number
46          */
47         private static final long serialVersionUID = 19_578_871_756_871L;
48
49         /**
50          * Ending day of opening hours (if applyable)
51          */
52         @Column (name = "opening_times_end_day")
53         @Enumerated (EnumType.STRING)
54         private DayOfWeek endDay;
55
56         /**
57          * Ending time (hh:mm)
58          */
59         @Basic (optional = false)
60         @Column (name = "opening_times_end_time", nullable = false)
61         @Temporal (TemporalType.TIME)
62         private Calendar endTime;
63
64         /**
65          * Id number
66          */
67         @Id
68         @Column (name = "opening_times_id", nullable = false, updatable = false)
69         @GeneratedValue (strategy = GenerationType.IDENTITY)
70         private Long id;
71
72         /**
73          * Starting day of opening times
74          */
75         @Basic (optional = false)
76         @Column (name = "opening_times_start_day", nullable = false)
77         @Enumerated (EnumType.STRING)
78         private DayOfWeek startDay;
79
80         /**
81          * Starting time (hh:mm)
82          */
83         @Basic (optional = false)
84         @Column (name = "opening_times_start_time", nullable = false)
85         @Temporal (TemporalType.TIME)
86         private Calendar startTime;
87
88         /**
89          * Default constructor
90          */
91         public BusinessOpeningTimes () {
92         }
93
94         /**
95          * Constructor with all field
96          * <p>
97          * @param endDay    End day
98          * @param endTime   End time
99          * @param id        Id number
100          * @param startDay  Start day
101          * @param startTime Start time
102          */
103         public BusinessOpeningTimes (final DayOfWeek endDay, final Calendar endTime, final Long id, final DayOfWeek startDay, final Calendar startTime) {
104                 // Call other constructor
105                 this(endDay, endTime, startDay, startTime);
106
107                 // Set id number
108                 this.id = id;
109         }
110
111         /**
112          * Constructor with all fields except id number
113          * <p>
114          * @param endDay    End day
115          * @param endTime   End time
116          * @param startDay  Start day
117          * @param startTime Start time
118          */
119         public BusinessOpeningTimes (final DayOfWeek endDay, final Calendar endTime, final DayOfWeek startDay, final Calendar startTime) {
120                 // Set all fields
121                 this.endDay = endDay;
122                 this.endTime = endTime;
123                 this.startDay = startDay;
124                 this.startTime = startTime;
125         }
126
127         @Override
128         public boolean equals (final Object obj) {
129                 if (this == obj) {
130                         return true;
131                 } else if (obj == null) {
132                         return false;
133                 } else if (this.getClass() != obj.getClass()) {
134                         return false;
135                 }
136
137                 final OpeningTimes openingTimes = (OpeningTimes) obj;
138
139                 if (!Objects.equals(this.getId(), openingTimes.getId())) {
140                         return false;
141                 } else if (this.getStartDay() != openingTimes.getStartDay()) {
142                         return false;
143                 } else if (this.getEndDay() != openingTimes.getEndDay()) {
144                         return false;
145                 } else if (!Objects.equals(this.getStartTime(), openingTimes.getStartTime())) {
146                         return false;
147                 } else if (!Objects.equals(this.getEndTime(), openingTimes.getEndTime())) {
148                         return false;
149                 }
150
151                 return true;
152         }
153
154         @Override
155         public int hashCode () {
156                 int hash = 7;
157
158                 hash = 97 * hash + Objects.hashCode(this.getId());
159                 hash = 97 * hash + Objects.hashCode(this.getStartDay());
160                 hash = 97 * hash + Objects.hashCode(this.getEndDay());
161                 hash = 97 * hash + Objects.hashCode(this.getStartTime());
162                 hash = 97 * hash + Objects.hashCode(this.getEndTime());
163
164                 return hash;
165         }
166
167         @Override
168         public DayOfWeek getEndDay () {
169                 return this.endDay;
170         }
171
172         @Override
173         public void setEndDay (final DayOfWeek endDay) {
174                 this.endDay = endDay;
175         }
176
177         @Override
178         @SuppressWarnings ("ReturnOfDateField")
179         public Calendar getEndTime () {
180                 return this.endTime;
181         }
182
183         @Override
184         @SuppressWarnings ("AssignmentToDateFieldFromParameter")
185         public void setEndTime (final Calendar endTime) {
186                 this.endTime = endTime;
187         }
188
189         @Override
190         public Long getId () {
191                 return this.id;
192         }
193
194         @Override
195         public void setId (Long id) {
196                 this.id = id;
197         }
198
199         @Override
200         public DayOfWeek getStartDay () {
201                 return this.startDay;
202         }
203
204         @Override
205         public void setStartDay (final DayOfWeek startDay) {
206                 this.startDay = startDay;
207         }
208
209         @Override
210         @SuppressWarnings ("ReturnOfDateField")
211         public Calendar getStartTime () {
212                 return this.startTime;
213         }
214
215         @Override
216         @SuppressWarnings ("AssignmentToDateFieldFromParameter")
217         public void setStartTime (final Calendar startTime) {
218                 this.startTime = startTime;
219         }
220
221 }