*/
package org.mxchange.jcountry.model.data;
+import java.text.MessageFormat;
import java.util.Date;
import java.util.Objects;
import javax.persistence.Basic;
@Column (name = "country_entry_created", nullable = false, updatable = false)
private Date countryEntryCreated;
+ /**
+ * TImestamp when this entry has been updated
+ */
+ @Temporal (TemporalType.TIMESTAMP)
+ @Column (name = "country_entry_updated", insertable = false)
+ private Date countryEntryUpdated;
+
/**
* Dial prefix to be dialed before the area/city number is dialed. In
* Germany, this is 0.
@Column (name = "country_phone_code", length = 2, nullable = false, updatable = false)
private Short countryPhoneCode;
+ /**
+ * Default constructor, required for the JPA
+ */
+ public CountryData () {
+ }
+
+ /**
+ * Constructor with all required fields
+ * <p>
+ * @param countryAbroadDialPrefix Abroad dial prefix
+ * @param countryCode 2-digit country code
+ * @param countryExternalDialPrefix External dial prefix
+ * @param countryI18nKey I18n key
+ * @param countryIsLocalPrefixRequired Whether local prefix is required to
+ * dial
+ * @param countryPhoneCode Phone code for country
+ */
+ public CountryData (final String countryAbroadDialPrefix, final String countryCode, final String countryExternalDialPrefix, final String countryI18nKey, final Boolean countryIsLocalPrefixRequired, final Short countryPhoneCode) {
+ // Invoke default constructor first
+ this();
+
+ // Are all parameter set?
+ if (null == countryAbroadDialPrefix) {
+ // Throw NPE
+ throw new NullPointerException("countryAbroadDialPrefix is null"); //NOI18N
+ } else if (countryAbroadDialPrefix.isEmpty()) {
+ // Throw IAE
+ throw new IllegalArgumentException("countryAbroadDialPrefix is empty"); //NOI18N
+ } else if (null == countryCode) {
+ // Throw NPE
+ throw new NullPointerException("countryCode is null"); //NOI18N
+ } else if (countryCode.isEmpty()) {
+ // Throw IAE
+ throw new IllegalArgumentException("countryCode is empty"); //NOI18N
+ } else if (null == countryI18nKey) {
+ // Throw NPE
+ throw new NullPointerException("countryI18nKey is null"); //NOI18N
+ } else if (countryI18nKey.isEmpty()) {
+ // Throw IAE
+ throw new IllegalArgumentException("countryI18nKey is empty"); //NOI18N
+ } else if (null == countryIsLocalPrefixRequired) {
+ // Throw NPE
+ throw new NullPointerException("countryIsLocalPrefixRequired is null"); //NOI18N
+ } else if (null == countryPhoneCode) {
+ // Throw NPE
+ throw new NullPointerException("countryPhoneCode is null"); //NOI18N
+ } else if (countryPhoneCode < 1) {
+ // Throw IAE
+ throw new IllegalArgumentException(MessageFormat.format("countryPhoneCode={0} is not valid, must be at least 1.", countryPhoneCode)); //NOI18N
+ }
+
+ // Set all fields
+ this.countryAbroadDialPrefix = countryAbroadDialPrefix;
+ this.countryCode = countryCode;
+ this.countryExternalDialPrefix = countryExternalDialPrefix;
+ this.countryI18nKey = countryI18nKey;
+ this.countryIsLocalPrefixRequired = countryIsLocalPrefixRequired;
+ this.countryPhoneCode = countryPhoneCode;
+ }
+
@Override
public int compareTo (final Country country) {
// Check parameter on null-reference and equality to this
this.countryEntryCreated = countryEntryCreated;
}
+ @Override
+ @SuppressWarnings ("ReturnOfDateField")
+ public Date getCountryEntryUpdated () {
+ return this.countryEntryUpdated;
+ }
+
+ @Override
+ @SuppressWarnings ("AssignmentToDateFieldFromParameter")
+ public void setCountryEntryUpdated (final Date countryEntryUpdated) {
+ this.countryEntryUpdated = countryEntryUpdated;
+ }
+
@Override
public String getCountryExternalDialPrefix () {
return this.countryExternalDialPrefix;