2 * Copyright (C) 2016, 2017 Roland Häder
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.jphone.model.phonenumbers.mobileprovider;
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.NamedQueries;
30 import javax.persistence.NamedQuery;
31 import javax.persistence.OneToOne;
32 import javax.persistence.Table;
33 import javax.persistence.Temporal;
34 import javax.persistence.TemporalType;
35 import javax.persistence.Transient;
36 import org.mxchange.jcountry.model.data.Country;
37 import org.mxchange.jcountry.model.data.CountryData;
40 * A POJO for cellphone providers
42 * @author Roland Häder<roland@mxchange.org>
44 @Entity (name = "mobile_provider")
45 @Table (name = "mobile_provider")
47 @NamedQuery (name = "AllMobileProvider", query = "SELECT p FROM mobile_provider AS p ORDER BY p.providerId ASC")
49 @SuppressWarnings ("PersistenceUnitPresent")
50 public class CellphoneProvider implements MobileProvider {
56 private static final long serialVersionUID = 185_878_567_810_590L;
59 * Country instance ('s dial data)
61 @JoinColumn (name = "provider_country_id", nullable = false)
62 @OneToOne (targetEntity = CountryData.class, cascade = CascadeType.REFRESH, optional = false)
63 private Country providerCountry;
66 * Provider dial prefix (example: 0177 for German E+)
68 @Basic (optional = false)
69 @Column (name = "provider_dial_prefix", length = 10, nullable = false)
70 private Long providerDialPrefix;
73 * Timestamp when this entry has been created
75 @Basic (optional = false)
76 @Temporal (TemporalType.TIMESTAMP)
77 @Column (name = "provider_entry_created", nullable = false, updatable = false)
78 private Calendar providerEntryCreated;
84 @GeneratedValue (strategy = GenerationType.IDENTITY)
85 @Column (name = "provider_id", nullable = false, updatable = false)
86 private Long providerId;
89 * Pattern for mail gateway
91 @Column (name = "provider_mail_pattern", length = 30)
92 private String providerMailPattern;
95 * Name of the provider
97 @Basic (optional = false)
98 @Column (name = "provider_name", length = 30, nullable = false)
99 private String providerName;
102 * Default constructor
104 public CellphoneProvider () {
108 * Constructor with all required data
110 * @param providerDialPrefix Dial prefix
111 * @param providerName Name
112 * @param providerCountry Country
113 * @param providerMailPattern Pattern for email
115 public CellphoneProvider (final Long providerDialPrefix, final String providerName, final Country providerCountry, final String providerMailPattern) {
116 // Call default constructor
120 this.providerDialPrefix = providerDialPrefix;
121 this.providerName = providerName;
122 this.providerCountry = providerCountry;
123 this.providerMailPattern = providerMailPattern;
127 public boolean equals (final Object object) {
128 if (null == object) {
130 } else if (this.getClass() != object.getClass()) {
134 final MobileProvider other = (MobileProvider) object;
136 if (!Objects.equals(this.getProviderDialPrefix(), other.getProviderDialPrefix())) {
138 } else if (!Objects.equals(this.getProviderName(), other.getProviderName())) {
140 } else if (!Objects.equals(this.getProviderCountry(), other.getProviderCountry())) {
148 public int hashCode () {
150 hash = 19 * hash + Objects.hashCode(this.getProviderDialPrefix());
151 hash = 19 * hash + Objects.hashCode(this.getProviderName());
152 hash = 19 * hash + Objects.hashCode(this.getProviderCountry());
157 public Country getProviderCountry () {
158 return this.providerCountry;
162 public void setProviderCountry (final Country providerCountry) {
163 this.providerCountry = providerCountry;
167 public Long getProviderDialPrefix () {
168 return this.providerDialPrefix;
172 public void setProviderDialPrefix (final Long providerDialPrefix) {
173 this.providerDialPrefix = providerDialPrefix;
177 @SuppressWarnings ("ReturnOfDateField")
178 public Calendar getProviderEntryCreated () {
179 return this.providerEntryCreated;
183 @SuppressWarnings ("AssignmentToDateFieldFromParameter")
184 public void setProviderEntryCreated (final Calendar providerEntryCreated) {
185 this.providerEntryCreated = providerEntryCreated;
189 public Long getProviderId () {
190 return this.providerId;
194 public void setProviderId (final Long providerId) {
195 this.providerId = providerId;
199 public String getProviderName () {
200 return this.providerName;
204 public void setProviderName (final String providerName) {
205 this.providerName = providerName;
209 public String getProviderMailPattern () {
210 return this.providerMailPattern;
214 public void setProviderMailPattern (final String providerMailPattern) {
215 this.providerMailPattern = providerMailPattern;