2 * Copyright (C) 2016 - 2020 Free Software Foundation
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.model.logo;
19 import java.util.Date;
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.jcoreutils.Comparables;
35 import org.mxchange.jusercore.model.user.LoginUser;
36 import org.mxchange.jusercore.model.user.User;
39 * A POJO for company logos
41 * @author Roland Häder<roland@mxchange.org>
43 @Entity (name = "company_logos")
44 @Table (name = "company_logos")
45 @SuppressWarnings ("PersistenceUnitPresent")
46 public class BusinessLogo implements Logo {
52 private static final long serialVersionUID = 475_871_875_718_751_285L;
55 * Timestamp when this entry has been created
57 @Basic (optional = false)
58 @Temporal (TemporalType.TIMESTAMP)
59 @Column (name = "logo_entry_created", nullable = false, updatable = false)
60 private Date logoCreated;
63 * Local file name of the logo (relative to /resources/logos/)
65 @Basic (optional = false)
66 @Column (name = "logo_file_name", nullable = false, unique = true, updatable = false)
67 private String logoFileName;
73 @GeneratedValue (strategy = GenerationType.IDENTITY)
74 @Column (name = "logo_id", nullable = false, updatable = false)
78 * Logo uploader user instance
80 @JoinColumn (name = "logo_uploader_id", nullable = false, updatable = false)
81 @OneToOne (targetEntity = LoginUser.class, cascade = CascadeType.REFRESH, optional = false)
82 private User logoUploader;
85 public int compareTo (final Logo logo) {
86 // Check parameter on null-reference and equality to this
89 throw new NullPointerException("logo is null"); //NOI18N
90 } else if (logo.equals(this)) {
96 final int[] comparators = {
97 // First file name ...
98 this.getLogoFileName().compareToIgnoreCase(logo.getLogoFileName()),
99 // ... then uploader instance
100 this.getLogoUploader().compareTo(logo.getLogoUploader())
104 final int comparison = Comparables.checkAll(comparators);
111 public boolean equals (final Object object) {
112 if (null == object) {
114 } else if (this.getClass() != object.getClass()) {
118 final Logo other = (Logo) object;
120 if (!Objects.equals(this.getLogoId(), other.getLogoId())) {
122 } else if (!Objects.equals(this.getLogoUploader(), other.getLogoUploader())) {
124 } else if (!Objects.equals(this.getLogoFileName(), other.getLogoFileName())) {
132 @SuppressWarnings ("ReturnOfDateField")
133 public Date getLogoCreated () {
134 return this.logoCreated;
138 @SuppressWarnings ("AssignmentToDateFieldFromParameter")
139 public void setLogoCreated (final Date logoCreated) {
140 this.logoCreated = logoCreated;
144 public String getLogoFileName () {
145 return this.logoFileName;
149 public void setLogoFileName (final String logoFileName) {
150 this.logoFileName = logoFileName;
154 public Long getLogoId () {
159 public void setLogoId (final Long logoId) {
160 this.logoId = logoId;
164 public User getLogoUploader () {
165 return this.logoUploader;
169 public void setLogoUploader (final User logoUploader) {
170 this.logoUploader = logoUploader;
174 public int hashCode () {
177 hash = 53 * hash + Objects.hashCode(this.getLogoId());
178 hash = 53 * hash + Objects.hashCode(this.getLogoFileName());
179 hash = 53 * hash + Objects.hashCode(this.getLogoUploader());