2 * Copyright (C) 2016 Roland Haeder
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.
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.
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/>.
17 package org.mxchange.jcontactsbusiness.opening_times;
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;
35 * A POJO for business opening hours
37 * @author Roland Haeder<roland@mxchange.org>
39 @Entity (name = "company_opening_times")
40 @Table (name = "company_opening_times")
41 @SuppressWarnings ("PersistenceUnitPresent")
42 public class BusinessOpeningTimes implements OpeningTimes {
47 private static final long serialVersionUID = 19_578_871_756_871L;
50 * Ending day of opening hours (if applyable)
52 @Column (name = "opening_times_end_day")
53 @Enumerated (EnumType.STRING)
54 private DayOfWeek endDay;
59 @Basic (optional = false)
60 @Column (name = "opening_times_end_time", nullable = false)
61 @Temporal (TemporalType.TIME)
62 private Calendar endTime;
68 @Column (name = "opening_times_id", nullable = false, updatable = false)
69 @GeneratedValue (strategy = GenerationType.IDENTITY)
73 * Starting day of opening times
75 @Basic (optional = false)
76 @Column (name = "opening_times_start_day", nullable = false)
77 @Enumerated (EnumType.STRING)
78 private DayOfWeek startDay;
81 * Starting time (hh:mm)
83 @Basic (optional = false)
84 @Column (name = "opening_times_start_time", nullable = false)
85 @Temporal (TemporalType.TIME)
86 private Calendar startTime;
91 public BusinessOpeningTimes () {
95 * Constructor with all field
97 * @param endDay End day
98 * @param endTime End time
100 * @param startDay Start day
101 * @param startTime Start time
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);
112 * Constructor with all fields except id number
114 * @param endDay End day
115 * @param endTime End time
116 * @param startDay Start day
117 * @param startTime Start time
119 public BusinessOpeningTimes (final DayOfWeek endDay, final Calendar endTime, final DayOfWeek startDay, final Calendar startTime) {
121 this.endDay = endDay;
122 this.endTime = endTime;
123 this.startDay = startDay;
124 this.startTime = startTime;
128 public boolean equals (final Object obj) {
131 } else if (obj == null) {
133 } else if (this.getClass() != obj.getClass()) {
137 final OpeningTimes openingTimes = (OpeningTimes) obj;
139 if (!Objects.equals(this.getId(), openingTimes.getId())) {
141 } else if (this.getStartDay() != openingTimes.getStartDay()) {
143 } else if (this.getEndDay() != openingTimes.getEndDay()) {
145 } else if (!Objects.equals(this.getStartTime(), openingTimes.getStartTime())) {
147 } else if (!Objects.equals(this.getEndTime(), openingTimes.getEndTime())) {
155 public int hashCode () {
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());
168 public DayOfWeek getEndDay () {
173 public void setEndDay (final DayOfWeek endDay) {
174 this.endDay = endDay;
178 @SuppressWarnings ("ReturnOfDateField")
179 public Calendar getEndTime () {
184 @SuppressWarnings ("AssignmentToDateFieldFromParameter")
185 public void setEndTime (final Calendar endTime) {
186 this.endTime = endTime;
190 public Long getId () {
195 public void setId (Long id) {
200 public DayOfWeek getStartDay () {
201 return this.startDay;
205 public void setStartDay (final DayOfWeek startDay) {
206 this.startDay = startDay;
210 @SuppressWarnings ("ReturnOfDateField")
211 public Calendar getStartTime () {
212 return this.startTime;
216 @SuppressWarnings ("AssignmentToDateFieldFromParameter")
217 public void setStartTime (final Calendar startTime) {
218 this.startTime = startTime;