]> git.mxchange.org Git - jphone-core.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Mon, 26 Jun 2017 18:48:27 +0000 (20:48 +0200)
committerRoland Häder <roland@mxchange.org>
Mon, 26 Jun 2017 18:48:27 +0000 (20:48 +0200)
- added utility classes which will be the homes for any non-getter/setter
  methods from POJOs as this is not recommended to have "complex" methods in
  POJOs (aka entity class)
- moved copyAll() methods to newly added utilities classes

Signed-off-by: Roland Häder <roland@mxchange.org>
12 files changed:
src/org/mxchange/jphone/phonenumbers/fax/DialableFaxNumber.java
src/org/mxchange/jphone/phonenumbers/fax/FaxNumber.java
src/org/mxchange/jphone/phonenumbers/fax/FaxNumbers.java [new file with mode: 0644]
src/org/mxchange/jphone/phonenumbers/landline/DialableLandLineNumber.java
src/org/mxchange/jphone/phonenumbers/landline/LandLineNumber.java
src/org/mxchange/jphone/phonenumbers/landline/LandLineNumbers.java [new file with mode: 0644]
src/org/mxchange/jphone/phonenumbers/mobile/DialableMobileNumber.java
src/org/mxchange/jphone/phonenumbers/mobile/MobileNumber.java
src/org/mxchange/jphone/phonenumbers/mobile/MobileNumbers.java [new file with mode: 0644]
src/org/mxchange/jphone/phonenumbers/mobileprovider/CellphoneProvider.java
src/org/mxchange/jphone/phonenumbers/mobileprovider/MobileProvider.java
src/org/mxchange/jphone/phonenumbers/mobileprovider/MobileProviders.java [new file with mode: 0644]

index 1e1226c7c3809bb170cf6b315a8d2f285fcd43ed..a8976c141b3f6612c1533aff513da61b66699207 100644 (file)
@@ -25,16 +25,10 @@ import org.mxchange.jphone.phonenumbers.DialableNumber;
  */
 public interface DialableFaxNumber extends DialableNumber {
 
-       /**
-        * Copy all fields from source object to this
-        * <p>
-        * @param sourceNumber Source number object
-        */
-       void copyAll (final DialableFaxNumber sourceNumber);
-
        @Override
        boolean equals (final Object object);
 
        @Override
        int hashCode ();
+
 }
index 40d112498e8100ca4055979c819580ef1cb73b87..bcea5cb84bcf23339d3e73da8709fabf2cf61c93 100644 (file)
@@ -125,22 +125,6 @@ public class FaxNumber implements DialableFaxNumber {
                this.phoneNumber = faxNumber;
        }
 
-       @Override
-       public void copyAll (final DialableFaxNumber sourceNumber) {
-               // Validate instance
-               if (null == sourceNumber) {
-                       // Throw NPE
-                       throw new NullPointerException("sourceNumber is null"); //NOI18N
-               }
-
-               // Copy all
-               this.setPhoneAreaCode(sourceNumber.getPhoneAreaCode());
-               this.getPhoneCountry().copyAll(sourceNumber.getPhoneCountry());
-               this.setPhoneEntryCreated(sourceNumber.getPhoneEntryCreated());
-               this.setPhoneId(sourceNumber.getPhoneId());
-               this.setPhoneNumber(sourceNumber.getPhoneNumber());
-       }
-
        @Override
        public boolean equals (final Object object) {
                if (null == object) {
diff --git a/src/org/mxchange/jphone/phonenumbers/fax/FaxNumbers.java b/src/org/mxchange/jphone/phonenumbers/fax/FaxNumbers.java
new file mode 100644 (file)
index 0000000..580f4df
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 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.jphone.phonenumbers.fax;
+
+import java.io.Serializable;
+
+/**
+ * An utilities class for fax numbers
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public class FaxNumbers implements Serializable {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 1_948_653_672_761L;
+
+       /**
+        * Copy all fields from source object to this
+        * <p>
+        * @param sourceNumber Source number object
+        * @param targetNumber Target number object
+        */
+       public static void copyAll (final DialableFaxNumber sourceNumber, final DialableFaxNumber targetNumber) {
+               // Validate instance
+               if (null == sourceNumber) {
+                       // Throw NPE
+                       throw new NullPointerException("sourceNumber is null"); //NOI18N
+               } else if (null == targetNumber) {
+                       // Throw NPE
+                       throw new NullPointerException("targetNumber is null"); //NOI18N
+               }
+
+               // Copy all
+               targetNumber.setPhoneAreaCode(sourceNumber.getPhoneAreaCode());
+               targetNumber.setPhoneCountry(sourceNumber.getPhoneCountry());
+               targetNumber.setPhoneEntryCreated(sourceNumber.getPhoneEntryCreated());
+               targetNumber.setPhoneId(sourceNumber.getPhoneId());
+               targetNumber.setPhoneNumber(sourceNumber.getPhoneNumber());
+       }
+
+       /**
+        * No constructor for utilities classes
+        */
+       private FaxNumbers () {
+       }
+
+}
index 10a20024a491faa3aa9e87b08d12f03fb17b1e06..5b5a04b2f46e7b2fc2b03384b2fe4f4d30c95293 100644 (file)
@@ -25,13 +25,6 @@ import org.mxchange.jphone.phonenumbers.DialableNumber;
  */
 public interface DialableLandLineNumber extends DialableNumber {
 
-       /**
-        * Copy all fields from source object to this
-        * <p>
-        * @param sourceNumber Source number object
-        */
-       void copyAll (final DialableLandLineNumber sourceNumber);
-
        @Override
        boolean equals (final Object object);
 
index 69ad3bcd22692765a08442a07a99b0c52eaa2a52..f7c809b74f1239801675b39337851ff451bc2aa2 100644 (file)
@@ -125,22 +125,6 @@ public class LandLineNumber implements DialableLandLineNumber {
                this.phoneNumber = phoneNumber;
        }
 
-       @Override
-       public void copyAll (final DialableLandLineNumber sourceNumber) {
-               // Validate instance
-               if (null == sourceNumber) {
-                       // Throw NPE
-                       throw new NullPointerException("sourceNumber is null"); //NOI18N
-               }
-
-               // Copy all
-               this.setPhoneAreaCode(sourceNumber.getPhoneAreaCode());
-               this.getPhoneCountry().copyAll(sourceNumber.getPhoneCountry());
-               this.setPhoneEntryCreated(sourceNumber.getPhoneEntryCreated());
-               this.setPhoneId(sourceNumber.getPhoneId());
-               this.setPhoneNumber(sourceNumber.getPhoneNumber());
-       }
-
        @Override
        public boolean equals (final Object object) {
                if (null == object) {
diff --git a/src/org/mxchange/jphone/phonenumbers/landline/LandLineNumbers.java b/src/org/mxchange/jphone/phonenumbers/landline/LandLineNumbers.java
new file mode 100644 (file)
index 0000000..6f67f7a
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 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 targetNumber program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jphone.phonenumbers.landline;
+
+import java.io.Serializable;
+
+/**
+ * An utilities class for land-line numbers
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public class LandLineNumbers implements Serializable {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 18_698_467_372_167_561L;
+
+       /**
+        * Copy all fields from source object to this
+        * <p>
+        * @param sourceNumber Source number object
+        * @param targetNumber Target number object
+        */
+       public static void copyAll (final DialableLandLineNumber sourceNumber, final DialableLandLineNumber targetNumber) {
+               // Validate instance
+               if (null == sourceNumber) {
+                       // Throw NPE
+                       throw new NullPointerException("sourceNumber is null"); //NOI18N
+               } else if (null == targetNumber) {
+                       // Throw NPE
+                       throw new NullPointerException("targetNumber is null"); //NOI18N
+               }
+
+               // Copy all
+               targetNumber.setPhoneAreaCode(sourceNumber.getPhoneAreaCode());
+               targetNumber.setPhoneCountry(sourceNumber.getPhoneCountry());
+               targetNumber.setPhoneEntryCreated(sourceNumber.getPhoneEntryCreated());
+               targetNumber.setPhoneId(sourceNumber.getPhoneId());
+               targetNumber.setPhoneNumber(sourceNumber.getPhoneNumber());
+       }
+
+       /**
+        * No constructor for utilities classes
+        */
+       private LandLineNumbers () {
+       }
+
+}
index 9c4fc7d2c2985464317b8c27f6b7bd217be63d5c..554b214f3ee2f78fd8afbe82002ae8a78455e173 100644 (file)
@@ -40,13 +40,6 @@ public interface DialableMobileNumber extends DialableNumber {
         */
        void setMobileProvider (final MobileProvider mobileProvider);
 
-       /**
-        * Copy all fields from source object to this
-        * <p>
-        * @param sourceNumber Source number object
-        */
-       void copyAll (final DialableMobileNumber sourceNumber);
-
        @Override
        boolean equals (final Object object);
 
index e3cf83f8266d486d552f87cd7181df0d56ab8c05..36e9e2aadcdb742da152b82bc7ad53560f0c9e4a 100644 (file)
@@ -34,7 +34,6 @@ import javax.persistence.Temporal;
 import javax.persistence.TemporalType;
 import javax.persistence.Transient;
 import org.mxchange.jcountry.data.Country;
-import org.mxchange.jphone.phonenumbers.mobileprovider.CellphoneProvider;
 import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider;
 
 /**
@@ -63,7 +62,7 @@ public class MobileNumber implements DialableMobileNumber {
         * Connection to table "mobile_provider" (for dial prefix and more data)
         */
        @JoinColumn (name = "mobile_provider_id", nullable = false)
-       @OneToOne (targetEntity = CellphoneProvider.class, cascade = CascadeType.REFRESH, optional = false)
+       @OneToOne (targetEntity = MobileProvider.class, cascade = CascadeType.REFRESH, optional = false)
        private MobileProvider mobileProvider;
 
        /**
@@ -117,21 +116,6 @@ public class MobileNumber implements DialableMobileNumber {
                this.phoneNumber = mobileNumber;
        }
 
-       @Override
-       public void copyAll (final DialableMobileNumber sourceNumber) {
-               // Validate instance
-               if (null == sourceNumber) {
-                       // Throw NPE
-                       throw new NullPointerException("sourceNumber is null"); //NOI18N
-               }
-
-               // Copy all
-               this.getMobileProvider().copyAll(sourceNumber.getMobileProvider());
-               this.setPhoneEntryCreated(sourceNumber.getPhoneEntryCreated());
-               this.setPhoneId(sourceNumber.getPhoneId());
-               this.setPhoneNumber(sourceNumber.getPhoneNumber());
-       }
-
        @Override
        public boolean equals (final Object object) {
                if (null == object) {
@@ -166,13 +150,13 @@ public class MobileNumber implements DialableMobileNumber {
        @Override
        @Deprecated
        public Integer getPhoneAreaCode () {
-               throw new UnsupportedOperationException("Cellphone numbers don't have area codes. Please fix your code."); //NOI18N
+               throw new UnsupportedOperationException("Mobile numbers don't have area codes. Please fix your code."); //NOI18N
        }
 
        @Override
        @Deprecated
        public void setPhoneAreaCode (final Integer phoneAreaCode) {
-               throw new UnsupportedOperationException("Cellphone numbers don't have area codes. Please fix your code."); //NOI18N
+               throw new UnsupportedOperationException("Mobile numbers don't have area codes. Please fix your code."); //NOI18N
        }
 
        @Override
diff --git a/src/org/mxchange/jphone/phonenumbers/mobile/MobileNumbers.java b/src/org/mxchange/jphone/phonenumbers/mobile/MobileNumbers.java
new file mode 100644 (file)
index 0000000..89e57f8
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 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 targetNumber program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jphone.phonenumbers.mobile;
+
+import java.io.Serializable;
+
+/**
+ * An utilities class for mobile numbers
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public class MobileNumbers implements Serializable {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 291_608_496_882_761L;
+
+       /**
+        * Copy all fields from source object to this
+        * <p>
+        * @param sourceNumber Source number object
+        * @param targetNumber Target number object
+        */
+       public static void copyAll (final DialableMobileNumber sourceNumber, final DialableMobileNumber targetNumber) {
+               // Validate instance
+               if (null == sourceNumber) {
+                       // Throw NPE
+                       throw new NullPointerException("sourceNumber is null"); //NOI18N
+               } else if (null == targetNumber) {
+                       // Throw NPE
+                       throw new NullPointerException("targetNumber is null"); //NOI18N
+               }
+
+               // Copy all fields
+               targetNumber.setMobileProvider(sourceNumber.getMobileProvider());
+               targetNumber.setPhoneEntryCreated(sourceNumber.getPhoneEntryCreated());
+               targetNumber.setPhoneId(sourceNumber.getPhoneId());
+               targetNumber.setPhoneNumber(sourceNumber.getPhoneNumber());
+       }
+
+       /**
+        * No constructor for utilities classes
+        */
+       private MobileNumbers () {
+       }
+
+}
index 1212ef5c2e8ac8cd9531615000caa136142188db..431a945d3e984a03022fb081e6f4a4a605aa6e3d 100644 (file)
@@ -123,23 +123,6 @@ public class CellphoneProvider implements MobileProvider {
                this.providerMailPattern = providerMailPattern;
        }
 
-       @Override
-       public void copyAll (final MobileProvider sourceMobileProvider) {
-               // Parameter should not be null
-               if (null == sourceMobileProvider) {
-                       // Throw NPE
-                       throw new NullPointerException("sourceMobileProvider is null"); //NOI18N
-               }
-
-               // Copy all values
-               this.getProviderCountry().copyAll(sourceMobileProvider.getProviderCountry());
-               this.setProviderDialPrefix(sourceMobileProvider.getProviderDialPrefix());
-               this.setProviderEntryCreated(sourceMobileProvider.getProviderEntryCreated());
-               this.setProviderId(sourceMobileProvider.getProviderId());
-               this.setProviderMailPattern(sourceMobileProvider.getProviderMailPattern());
-               this.setProviderName(sourceMobileProvider.getProviderName());
-       }
-
        @Override
        public boolean equals (final Object object) {
                if (null == object) {
index 3f2c13e3f1373379a31671f24127933ded5278dc..a5b328d1c399f241130c288c35899d2ee7d08df4 100644 (file)
@@ -27,13 +27,6 @@ import org.mxchange.jcountry.data.Country;
  */
 public interface MobileProvider extends Serializable {
 
-       /**
-        * Copies all values from source mobile provider to this
-        * <p>
-        * @param sourceMobileProvider Source mobile provider
-        */
-       void copyAll (final MobileProvider sourceMobileProvider);
-
        /**
         * Getter for id number
         * <p>
diff --git a/src/org/mxchange/jphone/phonenumbers/mobileprovider/MobileProviders.java b/src/org/mxchange/jphone/phonenumbers/mobileprovider/MobileProviders.java
new file mode 100644 (file)
index 0000000..c2e0b1e
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 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 targetMobileProvider program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jphone.phonenumbers.mobileprovider;
+
+import java.io.Serializable;
+
+/**
+ * An utilities class for mobile providers
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public class MobileProviders implements Serializable {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 15_468_608_721_651L;
+
+       /**
+        * Copies all values from source mobile provider to this
+        * <p>
+        * @param sourceMobileProvider Source mobile provider
+        * @param targetMobileProvider Target mobile provider
+        */
+       public static void copyAll (final MobileProvider sourceMobileProvider, final MobileProvider targetMobileProvider) {
+               // Parameter should not be null
+               if (null == sourceMobileProvider) {
+                       // Throw NPE
+                       throw new NullPointerException("sourceMobileProvider is null"); //NOI18N
+               } else if (null == targetMobileProvider) {
+                       // Throw NPE
+                       throw new NullPointerException("targetMobileProvider is null"); //NOI18N
+               }
+
+               // Copy all values
+               targetMobileProvider.getProviderCountry().copyAll(sourceMobileProvider.getProviderCountry());
+               targetMobileProvider.setProviderDialPrefix(sourceMobileProvider.getProviderDialPrefix());
+               targetMobileProvider.setProviderEntryCreated(sourceMobileProvider.getProviderEntryCreated());
+               targetMobileProvider.setProviderId(sourceMobileProvider.getProviderId());
+               targetMobileProvider.setProviderMailPattern(sourceMobileProvider.getProviderMailPattern());
+               targetMobileProvider.setProviderName(sourceMobileProvider.getProviderName());
+       }
+
+       /**
+        * Private constructor, because there is no need for an instance of
+        * targetMobileProvider class.
+        */
+       private MobileProviders () {
+       }
+
+}