]> git.mxchange.org Git - jcontacts-business-core.git/blob - src/org/mxchange/jcontactsbusiness/logo/CompanyLogo.java
Continued:
[jcontacts-business-core.git] / src / org / mxchange / jcontactsbusiness / logo / CompanyLogo.java
1 /*
2  * Copyright (C) 2016, 2017 Roland Häder
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.logo;
18
19 import java.util.Calendar;
20 import java.util.Objects;
21 import javax.persistence.Basic;
22 import javax.persistence.CascadeType;
23 import javax.persistence.Column;
24 import javax.persistence.Entity;
25 import javax.persistence.GeneratedValue;
26 import javax.persistence.GenerationType;
27 import javax.persistence.Id;
28 import javax.persistence.JoinColumn;
29 import javax.persistence.OneToOne;
30 import javax.persistence.Table;
31 import javax.persistence.Temporal;
32 import javax.persistence.TemporalType;
33 import javax.persistence.Transient;
34 import org.mxchange.jusercore.model.user.LoginUser;
35 import org.mxchange.jusercore.model.user.User;
36
37 /**
38  * A POJO for company logos
39  * <p>
40  * @author Roland Häder<roland@mxchange.org>
41  */
42 @Entity (name = "company_logos")
43 @Table (name = "company_logos")
44 @SuppressWarnings ("PersistenceUnitPresent")
45 public class CompanyLogo implements BusinessLogo {
46
47         /**
48          * Serial number
49          */
50         @Transient
51         private static final long serialVersionUID = 475_871_875_718_751_285L;
52
53         /**
54          * Timestamp when this entry has been created
55          */
56         @Basic (optional = false)
57         @Temporal (TemporalType.TIMESTAMP)
58         @Column (name = "logo_entry_created", nullable = false, updatable = false)
59         private Calendar logoCreated;
60
61         /**
62          * Local file name of the logo (relative to /resources/logos/)
63          */
64         @Basic (optional = false)
65         @Column (name = "logo_file_name", nullable = false, unique = true, updatable = false)
66         private String logoFileName;
67
68         /**
69          * Id number
70          */
71         @Id
72         @GeneratedValue (strategy = GenerationType.IDENTITY)
73         @Column (name = "logo_id", nullable = false, updatable = false)
74         private Long logoId;
75
76         /**
77          * Logo uploader user instance
78          */
79         @JoinColumn (name = "logo_uploader_id", nullable = false, updatable = false)
80         @OneToOne (targetEntity = LoginUser.class, cascade = CascadeType.REFRESH, optional = false)
81         private User logoUploader;
82
83         @Override
84         public boolean equals (final Object object) {
85                 if (null == object) {
86                         return false;
87                 } else if (this.getClass() != object.getClass()) {
88                         return false;
89                 }
90
91                 final BusinessLogo other = (BusinessLogo) object;
92
93                 if (!Objects.equals(this.getLogoId(), other.getLogoId())) {
94                         return false;
95                 } else if (!Objects.equals(this.getLogoUploader(), other.getLogoUploader())) {
96                         return false;
97                 } else if (!Objects.equals(this.getLogoFileName(), other.getLogoFileName())) {
98                         return false;
99                 }
100
101                 return true;
102         }
103
104         @Override
105         @SuppressWarnings ("ReturnOfDateField")
106         public Calendar getLogoCreated () {
107                 return this.logoCreated;
108         }
109
110         @Override
111         @SuppressWarnings ("AssignmentToDateFieldFromParameter")
112         public void setLogoCreated (final Calendar logoCreated) {
113                 this.logoCreated = logoCreated;
114         }
115
116         @Override
117         public String getLogoFileName () {
118                 return this.logoFileName;
119         }
120
121         @Override
122         public void setLogoFileName (final String logoFileName) {
123                 this.logoFileName = logoFileName;
124         }
125
126         @Override
127         public Long getLogoId () {
128                 return this.logoId;
129         }
130
131         @Override
132         public void setLogoId (final Long logoId) {
133                 this.logoId = logoId;
134         }
135
136         @Override
137         public User getLogoUploader () {
138                 return this.logoUploader;
139         }
140
141         @Override
142         public void setLogoUploader (final User logoUploader) {
143                 this.logoUploader = logoUploader;
144         }
145
146         @Override
147         public int hashCode () {
148                 int hash = 3;
149
150                 hash = 53 * hash + Objects.hashCode(this.getLogoId());
151                 hash = 53 * hash + Objects.hashCode(this.getLogoFileName());
152                 hash = 53 * hash + Objects.hashCode(this.getLogoUploader());
153
154                 return hash;
155         }
156
157 }