+++ /dev/null
-/*
- * Copyright (C) 2016, 2017 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jcountry.data;
-
-import java.io.Serializable;
-import java.util.Calendar;
-
-/**
- * A POJI for country data such as dial prefixes
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface Country extends Serializable {
-
- /**
- * Copies all entries from sounce country to this
- * <p>
- * @param sourceCountry Source country to copy from
- */
- void copyAll (final Country sourceCountry);
-
- /**
- * Getter for country code (example: 49 for Germany, 63 for Philippines)
- * <p>
- * @return Dial number without prefix
- */
- Short getCountryPhoneCode ();
-
- /**
- * Setter for country code (example: 49 for Germany, 63 for Philippines)
- * <p>
- * @param countryPhoneCode Country code
- */
- void setCountryPhoneCode (final Short countryPhoneCode);
-
- /**
- * Getter for id number
- * <p>
- * @return Id number
- */
- Long getCountryId ();
-
- /**
- * Setter for id number
- * <p>
- * @param countryId Id number
- */
- void setCountryId (final Long countryId);
-
- /**
- * Getter for 2-characters country code
- * <p>
- * @return Country code
- */
- String getCountryCode ();
-
- /**
- * Setter for 2-characters country code
- * <p>
- * @param countryCode Country code
- */
- void setCountryCode (final String countryCode);
-
- /**
- * Getter for local dial prefix
- * <p>
- * @return Local dial prefix
- */
- String getCountryExternalDialPrefix ();
-
- /**
- * Setter for local dial prefix
- * <p>
- * @param countryExternalDialPrefix Local dial prefix
- */
- void setCountryExternalDialPrefix (final String countryExternalDialPrefix);
-
- /**
- * Getter for abroad dial prefix
- * <p>
- * @return Abroad dial prefix
- */
- String getCountryAbroadDialPrefix ();
-
- /**
- * Setter for abroad dial prefix
- * <p>
- * @param countryAbroadDialPrefix Abroad dial prefix
- */
- void setCountryAbroadDialPrefix (final String countryAbroadDialPrefix);
-
- /**
- * Getter for i18n key for country name
- * <p>
- * @return i18n key for country name
- */
- String getCountryI18nKey ();
-
- /**
- * Setter for i18n key for country name
- * <p>
- * @param countryI18nKey i18n key for country name
- */
- void setCountryI18nKey (final String countryI18nKey);
-
- /**
- * Getter for whether the local dial prefix is required for local calls
- * <p>
- * @return Whether the local dial prefix is required
- */
- Boolean getCountryIsLocalPrefixRequired ();
-
- /**
- * Setter for whether the local dial prefix is required for local calls
- * <p>
- * @param countryIsLocalPrefixRequired Whether the local dial prefix is
- * required
- */
- void setCountryIsLocalPrefixRequired (final Boolean countryIsLocalPrefixRequired);
-
- /**
- * Getter for country entry created timestamp
- * <p>
- * @return Country entry created timestamp
- */
- Calendar getCountryEntryCreated ();
-
- /**
- * Setter for country entry created timestamp
- * <p>
- * @param countryEntryCreated Country entry created timestamp
- */
- void setCountryEntryCreated (final Calendar countryEntryCreated);
-
- @Override
- boolean equals (final Object object);
-
- @Override
- int hashCode ();
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2016, 2017 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jcountry.data;
-
-import java.util.Calendar;
-import java.util.Objects;
-import javax.persistence.Basic;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.NamedQueries;
-import javax.persistence.NamedQuery;
-import javax.persistence.Table;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
-import javax.persistence.Transient;
-
-/**
- * A POJO for country data
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Entity (name = "country_data")
-@Table (name = "country_data")
-@NamedQueries (
- {
- @NamedQuery (name = "AllCountries", query = "SELECT c FROM country_data AS c ORDER BY c.countryId ASC"),
- @NamedQuery (name = "SearchCountryByCodeI18nKey", query = "SELECT c FROM country_data AS c WHERE c.countryCode = :code OR c.countryI18nKey = :key")
- }
-)
-@SuppressWarnings ("PersistenceUnitPresent")
-public class CountryData implements Country {
-
- /**
- * Serial number
- */
- @Transient
- private static final long serialVersionUID = 14_853_982_718_509L;
-
- /**
- * Dial prefix to be dialed before an abroad number is being dialed. In
- * Germany this is "+" or 00.
- */
- @Basic (optional = false)
- @Column (name = "country_abroad_dial_prefix", length = 10)
- private String countryAbroadDialPrefix;
-
- /**
- * 2-characters country code, all upper-case (example: DE for Germany, PH
- * for Philippines)
- */
- @Basic (optional = false)
- @Column (name = "country_code", length = 2, nullable = false, unique = true)
- private String countryCode;
-
- /**
- * TImestamp when this entry has been created
- */
- @Basic (optional = false)
- @Temporal (TemporalType.TIMESTAMP)
- @Column (name = "country_entry_created", nullable = false, updatable = false)
- private Calendar countryEntryCreated;
-
- /**
- * Dial prefix to be dialed before the area/city number is dialed. In
- * Germany, this is 0.
- */
- @Basic (optional = false)
- @Column (name = "country_external_dial_prefix", length = 10)
- private String countryExternalDialPrefix;
-
- /**
- * Key to i18n key (to have translated country names)
- */
- @Basic (optional = false)
- @Column (name = "country_i18n_key", length = 100, nullable = false)
- private String countryI18nKey;
-
- /**
- * Id number
- */
- @Id
- @GeneratedValue (strategy = GenerationType.IDENTITY)
- @Column (name = "country_id", nullable = false, updatable = false)
- private Long countryId;
-
- /**
- * Is the local dialing prefix required or optional for calling numbers in
- * same area?
- */
- @Basic (optional = false)
- @Column (name = "country_is_local_prefix_required", nullable = false)
- private Boolean countryIsLocalPrefixRequired;
-
- /**
- * 2-digit country's phone code (example: 49 for Germany, 63 for
- * Philippines)
- */
- @Basic (optional = false)
- @Column (name = "country_phone_code", length = 2, nullable = false, updatable = false)
- private Short countryPhoneCode;
-
- @Override
- public void copyAll (final Country sourceCountry) {
- // Parameter should not be null
- if (null == sourceCountry) {
- // Throw NPE
- throw new NullPointerException("sourceCountry is null"); //NOI18N
- }
-
- // Copy all
- this.setCountryAbroadDialPrefix(sourceCountry.getCountryAbroadDialPrefix());
- this.setCountryCode(sourceCountry.getCountryCode());
- this.setCountryEntryCreated(sourceCountry.getCountryEntryCreated());
- this.setCountryExternalDialPrefix(sourceCountry.getCountryExternalDialPrefix());
- this.setCountryI18nKey(sourceCountry.getCountryI18nKey());
- this.setCountryId(sourceCountry.getCountryId());
- this.setCountryIsLocalPrefixRequired(sourceCountry.getCountryIsLocalPrefixRequired());
- this.setCountryPhoneCode(sourceCountry.getCountryPhoneCode());
- }
-
- @Override
- public boolean equals (final Object object) {
- if (this == object) {
- return true;
- } else if (null == object) {
- return false;
- } else if (this.getClass() != object.getClass()) {
- return false;
- }
-
- final Country other = (Country) object;
-
- if (!Objects.equals(this.getCountryId(), other.getCountryId())) {
- return false;
- } else if (!Objects.equals(this.getCountryCode(), other.getCountryCode())) {
- return false;
- } else if (!Objects.equals(this.getCountryI18nKey(), other.getCountryI18nKey())) {
- return false;
- }
-
- return true;
- }
-
- @Override
- public String getCountryAbroadDialPrefix () {
- return this.countryAbroadDialPrefix;
- }
-
- @Override
- public void setCountryAbroadDialPrefix (final String countryAbroadDialPrefix) {
- this.countryAbroadDialPrefix = countryAbroadDialPrefix;
- }
-
- @Override
- public String getCountryCode () {
- return this.countryCode;
- }
-
- @Override
- public void setCountryCode (final String countryCode) {
- this.countryCode = countryCode;
- }
-
- @Override
- @SuppressWarnings ("ReturnOfDateField")
- public Calendar getCountryEntryCreated () {
- return this.countryEntryCreated;
- }
-
- @Override
- @SuppressWarnings ("AssignmentToDateFieldFromParameter")
- public void setCountryEntryCreated (final Calendar countryEntryCreated) {
- this.countryEntryCreated = countryEntryCreated;
- }
-
- @Override
- public String getCountryExternalDialPrefix () {
- return this.countryExternalDialPrefix;
- }
-
- @Override
- public void setCountryExternalDialPrefix (final String countryExternalDialPrefix) {
- this.countryExternalDialPrefix = countryExternalDialPrefix;
- }
-
- @Override
- public String getCountryI18nKey () {
- return this.countryI18nKey;
- }
-
- @Override
- public void setCountryI18nKey (final String countryI18nKey) {
- this.countryI18nKey = countryI18nKey;
- }
-
- @Override
- public Long getCountryId () {
- return this.countryId;
- }
-
- @Override
- public void setCountryId (final Long countryId) {
- this.countryId = countryId;
- }
-
- @Override
- public Boolean getCountryIsLocalPrefixRequired () {
- return this.countryIsLocalPrefixRequired;
- }
-
- @Override
- public void setCountryIsLocalPrefixRequired (final Boolean countryIsLocalPrefixRequired) {
- this.countryIsLocalPrefixRequired = countryIsLocalPrefixRequired;
- }
-
- @Override
- public Short getCountryPhoneCode () {
- return this.countryPhoneCode;
- }
-
- @Override
- public void setCountryPhoneCode (final Short countryPhoneCode) {
- this.countryPhoneCode = countryPhoneCode;
- }
-
- @Override
- public int hashCode () {
- int hash = 7;
-
- hash = 41 * hash + Objects.hashCode(this.getCountryId());
- hash = 41 * hash + Objects.hashCode(this.getCountryCode());
- hash = 41 * hash + Objects.hashCode(this.getCountryI18nKey());
-
- return hash;
- }
-
-}
package org.mxchange.jcountry.events;
import java.text.MessageFormat;
-import org.mxchange.jcountry.data.Country;
+import org.mxchange.jcountry.model.data.Country;
/**
* An addedCountry triggered when the administrator adds a new country
package org.mxchange.jcountry.events;
import java.io.Serializable;
-import org.mxchange.jcountry.data.Country;
+import org.mxchange.jcountry.model.data.Country;
/**
* An interface for a country being added by the administrator.
package org.mxchange.jcountry.exceptions;
import java.text.MessageFormat;
-import org.mxchange.jcountry.data.Country;
+import org.mxchange.jcountry.model.data.Country;
/**
* An exception thrown when a country is already registered. This can be easily
--- /dev/null
+/*
+ * Copyright (C) 2016, 2017 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jcountry.model.data;
+
+import java.io.Serializable;
+import java.util.Calendar;
+
+/**
+ * A POJI for country data such as dial prefixes
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface Country extends Serializable {
+
+ /**
+ * Copies all entries from sounce country to this
+ * <p>
+ * @param sourceCountry Source country to copy from
+ */
+ void copyAll (final Country sourceCountry);
+
+ /**
+ * Getter for country code (example: 49 for Germany, 63 for Philippines)
+ * <p>
+ * @return Dial number without prefix
+ */
+ Short getCountryPhoneCode ();
+
+ /**
+ * Setter for country code (example: 49 for Germany, 63 for Philippines)
+ * <p>
+ * @param countryPhoneCode Country code
+ */
+ void setCountryPhoneCode (final Short countryPhoneCode);
+
+ /**
+ * Getter for id number
+ * <p>
+ * @return Id number
+ */
+ Long getCountryId ();
+
+ /**
+ * Setter for id number
+ * <p>
+ * @param countryId Id number
+ */
+ void setCountryId (final Long countryId);
+
+ /**
+ * Getter for 2-characters country code
+ * <p>
+ * @return Country code
+ */
+ String getCountryCode ();
+
+ /**
+ * Setter for 2-characters country code
+ * <p>
+ * @param countryCode Country code
+ */
+ void setCountryCode (final String countryCode);
+
+ /**
+ * Getter for local dial prefix
+ * <p>
+ * @return Local dial prefix
+ */
+ String getCountryExternalDialPrefix ();
+
+ /**
+ * Setter for local dial prefix
+ * <p>
+ * @param countryExternalDialPrefix Local dial prefix
+ */
+ void setCountryExternalDialPrefix (final String countryExternalDialPrefix);
+
+ /**
+ * Getter for abroad dial prefix
+ * <p>
+ * @return Abroad dial prefix
+ */
+ String getCountryAbroadDialPrefix ();
+
+ /**
+ * Setter for abroad dial prefix
+ * <p>
+ * @param countryAbroadDialPrefix Abroad dial prefix
+ */
+ void setCountryAbroadDialPrefix (final String countryAbroadDialPrefix);
+
+ /**
+ * Getter for i18n key for country name
+ * <p>
+ * @return i18n key for country name
+ */
+ String getCountryI18nKey ();
+
+ /**
+ * Setter for i18n key for country name
+ * <p>
+ * @param countryI18nKey i18n key for country name
+ */
+ void setCountryI18nKey (final String countryI18nKey);
+
+ /**
+ * Getter for whether the local dial prefix is required for local calls
+ * <p>
+ * @return Whether the local dial prefix is required
+ */
+ Boolean getCountryIsLocalPrefixRequired ();
+
+ /**
+ * Setter for whether the local dial prefix is required for local calls
+ * <p>
+ * @param countryIsLocalPrefixRequired Whether the local dial prefix is
+ * required
+ */
+ void setCountryIsLocalPrefixRequired (final Boolean countryIsLocalPrefixRequired);
+
+ /**
+ * Getter for country entry created timestamp
+ * <p>
+ * @return Country entry created timestamp
+ */
+ Calendar getCountryEntryCreated ();
+
+ /**
+ * Setter for country entry created timestamp
+ * <p>
+ * @param countryEntryCreated Country entry created timestamp
+ */
+ void setCountryEntryCreated (final Calendar countryEntryCreated);
+
+ @Override
+ boolean equals (final Object object);
+
+ @Override
+ int hashCode ();
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016, 2017 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jcountry.model.data;
+
+import java.util.Calendar;
+import java.util.Objects;
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import javax.persistence.Transient;
+
+/**
+ * A POJO for country data
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Entity (name = "country_data")
+@Table (name = "country_data")
+@NamedQueries (
+ {
+ @NamedQuery (name = "AllCountries", query = "SELECT c FROM country_data AS c ORDER BY c.countryId ASC"),
+ @NamedQuery (name = "SearchCountryByCodeI18nKey", query = "SELECT c FROM country_data AS c WHERE c.countryCode = :code OR c.countryI18nKey = :key")
+ }
+)
+@SuppressWarnings ("PersistenceUnitPresent")
+public class CountryData implements Country {
+
+ /**
+ * Serial number
+ */
+ @Transient
+ private static final long serialVersionUID = 14_853_982_718_509L;
+
+ /**
+ * Dial prefix to be dialed before an abroad number is being dialed. In
+ * Germany this is "+" or 00.
+ */
+ @Basic (optional = false)
+ @Column (name = "country_abroad_dial_prefix", length = 10)
+ private String countryAbroadDialPrefix;
+
+ /**
+ * 2-characters country code, all upper-case (example: DE for Germany, PH
+ * for Philippines)
+ */
+ @Basic (optional = false)
+ @Column (name = "country_code", length = 2, nullable = false, unique = true)
+ private String countryCode;
+
+ /**
+ * TImestamp when this entry has been created
+ */
+ @Basic (optional = false)
+ @Temporal (TemporalType.TIMESTAMP)
+ @Column (name = "country_entry_created", nullable = false, updatable = false)
+ private Calendar countryEntryCreated;
+
+ /**
+ * Dial prefix to be dialed before the area/city number is dialed. In
+ * Germany, this is 0.
+ */
+ @Basic (optional = false)
+ @Column (name = "country_external_dial_prefix", length = 10)
+ private String countryExternalDialPrefix;
+
+ /**
+ * Key to i18n key (to have translated country names)
+ */
+ @Basic (optional = false)
+ @Column (name = "country_i18n_key", length = 100, nullable = false)
+ private String countryI18nKey;
+
+ /**
+ * Id number
+ */
+ @Id
+ @GeneratedValue (strategy = GenerationType.IDENTITY)
+ @Column (name = "country_id", nullable = false, updatable = false)
+ private Long countryId;
+
+ /**
+ * Is the local dialing prefix required or optional for calling numbers in
+ * same area?
+ */
+ @Basic (optional = false)
+ @Column (name = "country_is_local_prefix_required", nullable = false)
+ private Boolean countryIsLocalPrefixRequired;
+
+ /**
+ * 2-digit country's phone code (example: 49 for Germany, 63 for
+ * Philippines)
+ */
+ @Basic (optional = false)
+ @Column (name = "country_phone_code", length = 2, nullable = false, updatable = false)
+ private Short countryPhoneCode;
+
+ @Override
+ public void copyAll (final Country sourceCountry) {
+ // Parameter should not be null
+ if (null == sourceCountry) {
+ // Throw NPE
+ throw new NullPointerException("sourceCountry is null"); //NOI18N
+ }
+
+ // Copy all
+ this.setCountryAbroadDialPrefix(sourceCountry.getCountryAbroadDialPrefix());
+ this.setCountryCode(sourceCountry.getCountryCode());
+ this.setCountryEntryCreated(sourceCountry.getCountryEntryCreated());
+ this.setCountryExternalDialPrefix(sourceCountry.getCountryExternalDialPrefix());
+ this.setCountryI18nKey(sourceCountry.getCountryI18nKey());
+ this.setCountryId(sourceCountry.getCountryId());
+ this.setCountryIsLocalPrefixRequired(sourceCountry.getCountryIsLocalPrefixRequired());
+ this.setCountryPhoneCode(sourceCountry.getCountryPhoneCode());
+ }
+
+ @Override
+ public boolean equals (final Object object) {
+ if (this == object) {
+ return true;
+ } else if (null == object) {
+ return false;
+ } else if (this.getClass() != object.getClass()) {
+ return false;
+ }
+
+ final Country other = (Country) object;
+
+ if (!Objects.equals(this.getCountryId(), other.getCountryId())) {
+ return false;
+ } else if (!Objects.equals(this.getCountryCode(), other.getCountryCode())) {
+ return false;
+ } else if (!Objects.equals(this.getCountryI18nKey(), other.getCountryI18nKey())) {
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public String getCountryAbroadDialPrefix () {
+ return this.countryAbroadDialPrefix;
+ }
+
+ @Override
+ public void setCountryAbroadDialPrefix (final String countryAbroadDialPrefix) {
+ this.countryAbroadDialPrefix = countryAbroadDialPrefix;
+ }
+
+ @Override
+ public String getCountryCode () {
+ return this.countryCode;
+ }
+
+ @Override
+ public void setCountryCode (final String countryCode) {
+ this.countryCode = countryCode;
+ }
+
+ @Override
+ @SuppressWarnings ("ReturnOfDateField")
+ public Calendar getCountryEntryCreated () {
+ return this.countryEntryCreated;
+ }
+
+ @Override
+ @SuppressWarnings ("AssignmentToDateFieldFromParameter")
+ public void setCountryEntryCreated (final Calendar countryEntryCreated) {
+ this.countryEntryCreated = countryEntryCreated;
+ }
+
+ @Override
+ public String getCountryExternalDialPrefix () {
+ return this.countryExternalDialPrefix;
+ }
+
+ @Override
+ public void setCountryExternalDialPrefix (final String countryExternalDialPrefix) {
+ this.countryExternalDialPrefix = countryExternalDialPrefix;
+ }
+
+ @Override
+ public String getCountryI18nKey () {
+ return this.countryI18nKey;
+ }
+
+ @Override
+ public void setCountryI18nKey (final String countryI18nKey) {
+ this.countryI18nKey = countryI18nKey;
+ }
+
+ @Override
+ public Long getCountryId () {
+ return this.countryId;
+ }
+
+ @Override
+ public void setCountryId (final Long countryId) {
+ this.countryId = countryId;
+ }
+
+ @Override
+ public Boolean getCountryIsLocalPrefixRequired () {
+ return this.countryIsLocalPrefixRequired;
+ }
+
+ @Override
+ public void setCountryIsLocalPrefixRequired (final Boolean countryIsLocalPrefixRequired) {
+ this.countryIsLocalPrefixRequired = countryIsLocalPrefixRequired;
+ }
+
+ @Override
+ public Short getCountryPhoneCode () {
+ return this.countryPhoneCode;
+ }
+
+ @Override
+ public void setCountryPhoneCode (final Short countryPhoneCode) {
+ this.countryPhoneCode = countryPhoneCode;
+ }
+
+ @Override
+ public int hashCode () {
+ int hash = 7;
+
+ hash = 41 * hash + Objects.hashCode(this.getCountryId());
+ hash = 41 * hash + Objects.hashCode(this.getCountryCode());
+ hash = 41 * hash + Objects.hashCode(this.getCountryI18nKey());
+
+ return hash;
+ }
+
+}