]> git.mxchange.org Git - jphone-core.git/blob - src/org/mxchange/jphone/model/phonenumbers/mobileprovider/CellphoneProvider.java
ab39a7b821dbcecd57895d23119f40a938db0355
[jphone-core.git] / src / org / mxchange / jphone / model / phonenumbers / mobileprovider / CellphoneProvider.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.jphone.model.phonenumbers.mobileprovider;
18
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.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;
38
39 /**
40  * A POJO for cellphone providers
41  * <p>
42  * @author Roland Häder<roland@mxchange.org>
43  */
44 @Entity (name = "mobile_provider")
45 @Table (name = "mobile_provider")
46 @NamedQueries (
47                 @NamedQuery (name = "AllMobileProvider", query = "SELECT p FROM mobile_provider AS p ORDER BY p.providerId ASC")
48 )
49 @SuppressWarnings ("PersistenceUnitPresent")
50 public class CellphoneProvider implements MobileProvider {
51
52         /**
53          * Serial number
54          */
55         @Transient
56         private static final long serialVersionUID = 185_878_567_810_590L;
57
58         /**
59          * Country instance ('s dial data)
60          */
61         @JoinColumn (name = "provider_country_id", nullable = false)
62         @OneToOne (targetEntity = CountryData.class, cascade = CascadeType.REFRESH, optional = false)
63         private Country providerCountry;
64
65         /**
66          * Provider dial prefix (example: 0177 for German E+)
67          */
68         @Basic (optional = false)
69         @Column (name = "provider_dial_prefix", length = 10, nullable = false)
70         private Long providerDialPrefix;
71
72         /**
73          * Timestamp when this entry has been created
74          */
75         @Basic (optional = false)
76         @Temporal (TemporalType.TIMESTAMP)
77         @Column (name = "provider_entry_created", nullable = false, updatable = false)
78         private Date providerEntryCreated;
79
80         /**
81          * Id number
82          */
83         @Id
84         @GeneratedValue (strategy = GenerationType.IDENTITY)
85         @Column (name = "provider_id", nullable = false, updatable = false)
86         private Long providerId;
87
88         /**
89          * Pattern for mail gateway
90          */
91         @Column (name = "provider_mail_pattern", length = 30)
92         private String providerMailPattern;
93
94         /**
95          * Name of the provider
96          */
97         @Basic (optional = false)
98         @Column (name = "provider_name", length = 30, nullable = false)
99         private String providerName;
100
101         /**
102          * Default constructor
103          */
104         public CellphoneProvider () {
105         }
106
107         /**
108          * Constructor with all required data
109          * <p>
110          * @param providerDialPrefix  Dial prefix
111          * @param providerName        Name
112          * @param providerCountry     Country
113          * @param providerMailPattern Pattern for email
114          */
115         public CellphoneProvider (final Long providerDialPrefix, final String providerName, final Country providerCountry, final String providerMailPattern) {
116                 // Call default constructor
117                 this();
118
119                 // Set all values
120                 this.providerDialPrefix = providerDialPrefix;
121                 this.providerName = providerName;
122                 this.providerCountry = providerCountry;
123                 this.providerMailPattern = providerMailPattern;
124         }
125
126         @Override
127         public boolean equals (final Object object) {
128                 if (null == object) {
129                         return false;
130                 } else if (this.getClass() != object.getClass()) {
131                         return false;
132                 }
133
134                 final MobileProvider other = (MobileProvider) object;
135
136                 if (!Objects.equals(this.getProviderDialPrefix(), other.getProviderDialPrefix())) {
137                         return false;
138                 } else if (!Objects.equals(this.getProviderName(), other.getProviderName())) {
139                         return false;
140                 } else if (!Objects.equals(this.getProviderCountry(), other.getProviderCountry())) {
141                         return false;
142                 }
143
144                 return true;
145         }
146
147         @Override
148         public int hashCode () {
149                 int hash = 7;
150                 hash = 19 * hash + Objects.hashCode(this.getProviderDialPrefix());
151                 hash = 19 * hash + Objects.hashCode(this.getProviderName());
152                 hash = 19 * hash + Objects.hashCode(this.getProviderCountry());
153                 return hash;
154         }
155
156         @Override
157         public Country getProviderCountry () {
158                 return this.providerCountry;
159         }
160
161         @Override
162         public void setProviderCountry (final Country providerCountry) {
163                 this.providerCountry = providerCountry;
164         }
165
166         @Override
167         public Long getProviderDialPrefix () {
168                 return this.providerDialPrefix;
169         }
170
171         @Override
172         public void setProviderDialPrefix (final Long providerDialPrefix) {
173                 this.providerDialPrefix = providerDialPrefix;
174         }
175
176         @Override
177         @SuppressWarnings ("ReturnOfDateField")
178         public Date getProviderEntryCreated () {
179                 return this.providerEntryCreated;
180         }
181
182         @Override
183         @SuppressWarnings ("AssignmentToDateFieldFromParameter")
184         public void setProviderEntryCreated (final Date providerEntryCreated) {
185                 this.providerEntryCreated = providerEntryCreated;
186         }
187
188         @Override
189         public Long getProviderId () {
190                 return this.providerId;
191         }
192
193         @Override
194         public void setProviderId (final Long providerId) {
195                 this.providerId = providerId;
196         }
197
198         @Override
199         public String getProviderName () {
200                 return this.providerName;
201         }
202
203         @Override
204         public void setProviderName (final String providerName) {
205                 this.providerName = providerName;
206         }
207
208         @Override
209         public String getProviderMailPattern () {
210                 return this.providerMailPattern;
211         }
212
213         @Override
214         public void setProviderMailPattern (final String providerMailPattern) {
215                 this.providerMailPattern = providerMailPattern;
216         }
217
218 }