]> git.mxchange.org Git - jcontacts-business-core.git/blob - src/org/mxchange/jcontactsbusiness/opening_times/BusinessOpeningTimes.java
e030964db2dc12199494610d90ae299c7c23b957
[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 = "opening_times")
40 @Table (name = "opening_times")
41 public class BusinessOpeningTimes implements OpeningTimes {
42
43         /**
44          * Serial number
45          */
46         private static final long serialVersionUID = 19_578_871_756_871L;
47
48         /**
49          * Ending day of opening hours (if applyable)
50          */
51         @Column (name = "opening_times_end_day")
52         @Enumerated (EnumType.STRING)
53         private DayOfWeek endDay;
54
55         /**
56          * Ending time (hh:mm)
57          */
58         @Basic (optional = false)
59         @Column (name = "opening_times_end_time")
60         @Temporal (TemporalType.TIME)
61         private Calendar endTime;
62
63         /**
64          * Id number
65          */
66         @Id
67         @Column (name = "opening_times_id", nullable = false, updatable = false)
68         @GeneratedValue (strategy = GenerationType.IDENTITY)
69         private Long id;
70
71         /**
72          * Starting day of opening times
73          */
74         @Basic (optional = false)
75         @Column (name = "opening_times_start_day", nullable = false)
76         @Enumerated (EnumType.STRING)
77         private DayOfWeek startDay;
78
79         /**
80          * Starting time (hh:mm)
81          */
82         @Basic (optional = false)
83         @Column (name = "opening_times_start_time")
84         @Temporal (TemporalType.TIME)
85         private Calendar startTime;
86
87         @Override
88         public boolean equals (final Object obj) {
89                 if (this == obj) {
90                         return true;
91                 } else if (obj == null) {
92                         return false;
93                 } else if (this.getClass() != obj.getClass()) {
94                         return false;
95                 }
96
97                 final OpeningTimes openingTimes = (OpeningTimes) obj;
98
99                 if (!Objects.equals(this.getId(), openingTimes.getId())) {
100                         return false;
101                 } else if (this.getStartDay() != openingTimes.getStartDay()) {
102                         return false;
103                 } else if (this.getEndDay() != openingTimes.getEndDay()) {
104                         return false;
105                 } else if (!Objects.equals(this.getStartTime(), openingTimes.getStartTime())) {
106                         return false;
107                 } else if (!Objects.equals(this.getEndTime(), openingTimes.getEndTime())) {
108                         return false;
109                 }
110
111                 return true;
112         }
113
114         @Override
115         public int hashCode () {
116                 int hash = 7;
117
118                 hash = 97 * hash + Objects.hashCode(this.getId());
119                 hash = 97 * hash + Objects.hashCode(this.getStartDay());
120                 hash = 97 * hash + Objects.hashCode(this.getEndDay());
121                 hash = 97 * hash + Objects.hashCode(this.getStartTime());
122                 hash = 97 * hash + Objects.hashCode(this.getEndTime());
123
124                 return hash;
125         }
126
127         @Override
128         public DayOfWeek getEndDay () {
129                 return this.endDay;
130         }
131
132         @Override
133         public void setEndDay (final DayOfWeek endDay) {
134                 this.endDay = endDay;
135         }
136
137         @Override
138         public Calendar getEndTime () {
139                 return this.endTime;
140         }
141
142         @Override
143         public void setEndTime (final Calendar endTime) {
144                 this.endTime = endTime;
145         }
146
147         @Override
148         public Long getId () {
149                 return this.id;
150         }
151
152         @Override
153         public void setId (Long id) {
154                 this.id = id;
155         }
156
157         @Override
158         public DayOfWeek getStartDay () {
159                 return this.startDay;
160         }
161
162         @Override
163         public void setStartDay (final DayOfWeek startDay) {
164                 this.startDay = startDay;
165         }
166
167         @Override
168         public Calendar getStartTime () {
169                 return this.startTime;
170         }
171
172         @Override
173         public void setStartTime (final Calendar startTime) {
174                 this.startTime = startTime;
175         }
176
177 }