From f741c8c4c5c3247a6757393e536d7be5771f3cec Mon Sep 17 00:00:00 2001
From: Roland Haeder <roland@mxchange.org>
Date: Sat, 10 Oct 2015 22:51:23 +0200
Subject: [PATCH] added country instance to all number types and cell phone
 provider

---
 .../jphone/phonenumbers/DialableNumber.java   | 15 ++++++++++++
 .../cellphone/CellphoneNumber.java            | 19 +++++++++++++++
 .../jphone/phonenumbers/fax/FaxNumber.java    | 24 ++++++++++++++++++-
 .../phonenumbers/landline/LandLineNumber.java | 16 ++++++++++---
 .../smsprovider/CellphoneProvider.java        | 22 +++++++++++++++++
 .../phonenumbers/smsprovider/SmsProvider.java | 15 ++++++++++++
 6 files changed, 107 insertions(+), 4 deletions(-)

diff --git a/src/org/mxchange/jphone/phonenumbers/DialableNumber.java b/src/org/mxchange/jphone/phonenumbers/DialableNumber.java
index e7393cd..2c157f6 100644
--- a/src/org/mxchange/jphone/phonenumbers/DialableNumber.java
+++ b/src/org/mxchange/jphone/phonenumbers/DialableNumber.java
@@ -17,6 +17,7 @@
 package org.mxchange.jphone.phonenumbers;
 
 import java.io.Serializable;
+import org.mxchange.jcountry.data.Country;
 
 /**
  * A POJO for dialable numbers
@@ -25,6 +26,20 @@ import java.io.Serializable;
  */
 public interface DialableNumber extends Serializable {
 
+	/**
+	 * Getter for country instance ('s dial data)
+	 * <p>
+	 * @return Country instance
+	 */
+	public Country getCountry ();
+
+	/**
+	 * Setter for country instance ('s dial data)
+	 * <p>
+	 * @param country Country instance
+	 */
+	public void setCountry (final Country country);
+
 	/**
 	 * Getter for id number
 	 * <p>
diff --git a/src/org/mxchange/jphone/phonenumbers/cellphone/CellphoneNumber.java b/src/org/mxchange/jphone/phonenumbers/cellphone/CellphoneNumber.java
index 691b4b3..d06a3bb 100644
--- a/src/org/mxchange/jphone/phonenumbers/cellphone/CellphoneNumber.java
+++ b/src/org/mxchange/jphone/phonenumbers/cellphone/CellphoneNumber.java
@@ -26,6 +26,8 @@ import javax.persistence.Id;
 import javax.persistence.JoinColumn;
 import javax.persistence.OneToOne;
 import javax.persistence.Table;
+import org.mxchange.jcountry.data.Country;
+import org.mxchange.jcountry.data.CountryData;
 import org.mxchange.jphone.phonenumbers.smsprovider.CellphoneProvider;
 import org.mxchange.jphone.phonenumbers.smsprovider.SmsProvider;
 
@@ -65,6 +67,13 @@ public class CellphoneNumber implements DialableCellphoneNumber, Comparable<Dial
 	@Column (name = "cellphone_number", length = 20, nullable = false)
 	private Long phoneNumber;
 
+	/**
+	 * Country instance ('s dial data)
+	 */
+	@JoinColumn (name = "cellphone_country_id", nullable = false)
+	@OneToOne (targetEntity = CountryData.class, optional = false, cascade = CascadeType.ALL)
+	private Country country;
+
 	@Override
 	public Long getPhoneId () {
 		return this.phoneId;
@@ -109,4 +118,14 @@ public class CellphoneNumber implements DialableCellphoneNumber, Comparable<Dial
 	public int compareTo (final DialableCellphoneNumber dialableCellphoneNumber) {
 		throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
 	}
+
+	@Override
+	public Country getCountry () {
+		return this.country;
+	}
+
+	@Override
+	public void setCountry (final Country country) {
+		this.country = country;
+	}
 }
diff --git a/src/org/mxchange/jphone/phonenumbers/fax/FaxNumber.java b/src/org/mxchange/jphone/phonenumbers/fax/FaxNumber.java
index 7aecf88..16cdec0 100644
--- a/src/org/mxchange/jphone/phonenumbers/fax/FaxNumber.java
+++ b/src/org/mxchange/jphone/phonenumbers/fax/FaxNumber.java
@@ -17,12 +17,17 @@
 package org.mxchange.jphone.phonenumbers.fax;
 
 import javax.persistence.Basic;
+import javax.persistence.CascadeType;
 import javax.persistence.Column;
 import javax.persistence.Entity;
 import javax.persistence.GeneratedValue;
 import javax.persistence.GenerationType;
 import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.OneToOne;
 import javax.persistence.Table;
+import org.mxchange.jcountry.data.Country;
+import org.mxchange.jcountry.data.CountryData;
 
 /**
  * A POJO for dialable fax numbers
@@ -42,7 +47,7 @@ public class FaxNumber implements DialableFaxNumber, Comparable<DialableFaxNumbe
 	 * Id number
 	 */
 	@Id
-	@GeneratedValue(strategy = GenerationType.IDENTITY)
+	@GeneratedValue (strategy = GenerationType.IDENTITY)
 	@Column (name = "fax_id", length = 20, nullable = false, updatable = false)
 	private Long phoneId;
 
@@ -60,6 +65,13 @@ public class FaxNumber implements DialableFaxNumber, Comparable<DialableFaxNumbe
 	@Column (name = "fax_area_code", length = 10, nullable = false)
 	private Integer phoneAreaCode;
 
+	/**
+	 * Country instance ('s dial data)
+	 */
+	@JoinColumn (name = "fax_country_id", nullable = false)
+	@OneToOne (targetEntity = CountryData.class, optional = false, cascade = CascadeType.ALL)
+	private Country country;
+
 	@Override
 	public Long getPhoneId () {
 		return this.phoneId;
@@ -95,4 +107,14 @@ public class FaxNumber implements DialableFaxNumber, Comparable<DialableFaxNumbe
 		this.phoneAreaCode = phoneAreaCode;
 	}
 
+	@Override
+	public Country getCountry () {
+		return this.country;
+	}
+
+	@Override
+	public void setCountry (final Country country) {
+		this.country = country;
+	}
+
 }
diff --git a/src/org/mxchange/jphone/phonenumbers/landline/LandLineNumber.java b/src/org/mxchange/jphone/phonenumbers/landline/LandLineNumber.java
index d1b265e..73d4145 100644
--- a/src/org/mxchange/jphone/phonenumbers/landline/LandLineNumber.java
+++ b/src/org/mxchange/jphone/phonenumbers/landline/LandLineNumber.java
@@ -68,9 +68,9 @@ public class LandLineNumber implements DialableLandLineNumber, Comparable<Dialab
 	/**
 	 * Connection to table "country_data"
 	 */
-	@JoinColumn(name = "phone_country_id", nullable = false, updatable = false)
-	@OneToOne(targetEntity = CountryData.class, cascade = CascadeType.ALL, optional = false)
-	private Country phoneCountry;
+	@JoinColumn (name = "phone_country_id", nullable = false, updatable = false)
+	@OneToOne (targetEntity = CountryData.class, cascade = CascadeType.ALL, optional = false)
+	private Country country;
 
 	@Override
 	public Long getPhoneId () {
@@ -106,4 +106,14 @@ public class LandLineNumber implements DialableLandLineNumber, Comparable<Dialab
 	public int compareTo (final DialableLandLineNumber dialableNumber) {
 		throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
 	}
+
+	@Override
+	public Country getCountry () {
+		return this.country;
+	}
+
+	@Override
+	public void setCountry (final Country country) {
+		this.country = country;
+	}
 }
diff --git a/src/org/mxchange/jphone/phonenumbers/smsprovider/CellphoneProvider.java b/src/org/mxchange/jphone/phonenumbers/smsprovider/CellphoneProvider.java
index f879aee..d1f7fcd 100644
--- a/src/org/mxchange/jphone/phonenumbers/smsprovider/CellphoneProvider.java
+++ b/src/org/mxchange/jphone/phonenumbers/smsprovider/CellphoneProvider.java
@@ -16,12 +16,17 @@
  */
 package org.mxchange.jphone.phonenumbers.smsprovider;
 
+import javax.persistence.CascadeType;
 import javax.persistence.Column;
 import javax.persistence.Entity;
 import javax.persistence.GeneratedValue;
 import javax.persistence.GenerationType;
 import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.OneToOne;
 import javax.persistence.Table;
+import org.mxchange.jcountry.data.Country;
+import org.mxchange.jcountry.data.CountryData;
 
 /**
  * A POJO for cellphone providers
@@ -55,6 +60,13 @@ public class CellphoneProvider implements SmsProvider {
 	 */
 	private String providerName;
 
+	/**
+	 * Country instance ('s dial data)
+	 */
+	@JoinColumn (name = "provider_country_id", nullable = false)
+	@OneToOne (targetEntity = CountryData.class, optional = false, cascade = CascadeType.ALL)
+	private Country country;
+
 	@Override
 	public Long getProviderId () {
 		return providerId;
@@ -85,4 +97,14 @@ public class CellphoneProvider implements SmsProvider {
 		this.providerName = providerName;
 	}
 
+	@Override
+	public Country getCountry () {
+		return this.country;
+	}
+
+	@Override
+	public void setCountry (final Country country) {
+		this.country = country;
+	}
+
 }
diff --git a/src/org/mxchange/jphone/phonenumbers/smsprovider/SmsProvider.java b/src/org/mxchange/jphone/phonenumbers/smsprovider/SmsProvider.java
index 557057d..fc096c1 100644
--- a/src/org/mxchange/jphone/phonenumbers/smsprovider/SmsProvider.java
+++ b/src/org/mxchange/jphone/phonenumbers/smsprovider/SmsProvider.java
@@ -17,6 +17,7 @@
 package org.mxchange.jphone.phonenumbers.smsprovider;
 
 import java.io.Serializable;
+import org.mxchange.jcountry.data.Country;
 
 /**
  * A POJO for SMS provider
@@ -66,4 +67,18 @@ public interface SmsProvider extends Serializable {
 	 * @param providerName Provider name
 	 */
 	public void setProviderName (final String providerName);
+
+	/**
+	 * Getter for country instance ('s dial data)
+	 * <p>
+	 * @return Country instance
+	 */
+	public Country getCountry ();
+
+	/**
+	 * Setter for country instance ('s dial data)
+	 * <p>
+	 * @param country Country instance
+	 */
+	public void setCountry (final Country country);
 }
-- 
2.39.5