]> git.mxchange.org Git - jcontacts-business-core.git/blobdiff - src/org/mxchange/jcontactsbusiness/model/branchoffice/BranchOffices.java
Continued:
[jcontacts-business-core.git] / src / org / mxchange / jcontactsbusiness / model / branchoffice / BranchOffices.java
index a5897c7569011190381ecb92391468326b1ed89c..2742a5e268c7d3b47afcbbec447c4779de5f3e8c 100644 (file)
@@ -1,5 +1,6 @@
+
 /*
- * Copyright (C) 2017 Free Software Foundation
+ * Copyright (C) 2017 - 2020 Free Software Foundation
  *
  * 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
@@ -31,6 +32,73 @@ public class BranchOffices implements Serializable {
         */
        private static final long serialVersionUID = 69_537_867_224_651L;
 
+       /**
+        * Compares both branch office instances. This method returns -1 if second
+        * instance is null.
+        * <p>
+        * @param branchOffice1 Branch office instance 1
+        * @param branchOffice2 Branch office instance 2
+        * <p>
+        * @return Comparison value
+        */
+       public static int compare (final BranchOffice branchOffice1, final BranchOffice branchOffice2) {
+               // Check euqality, then at least first must be given
+               if (Objects.equals(branchOffice1, branchOffice2)) {
+                       // Both are same
+                       return 0;
+               } else if (null == branchOffice1) {
+                       // First is null
+                       return -1;
+               } else if (null == branchOffice2) {
+                       // Second is null
+                       return 1;
+               }
+
+               // Invoke compareTo() method
+               return branchOffice1.compareTo(branchOffice2);
+       }
+
+       /**
+        * Copies all fields from source to target branch office instance
+        * <p>
+        * @param sourceBranchOffice Source BranchOffice instance
+        * @param targetBranchOffice Target BranchOffice instance
+        */
+       public static void copyBranchOfficeData (final BranchOffice sourceBranchOffice, final BranchOffice targetBranchOffice) {
+               // Check that both parameters are not null
+               if (null == sourceBranchOffice) {
+                       // Throw NPE
+                       throw new NullPointerException("sourceBranchOffice is null"); //NOI18N
+               } else if (null == targetBranchOffice) {
+                       // Throw NPE
+                       throw new NullPointerException("targetBranchOffice is null"); //NOI18N
+               } else if (Objects.equals(sourceBranchOffice, targetBranchOffice)) {
+                       // Throw IAE
+                       throw new IllegalArgumentException("sourceBranchOffice and targetBranchOffice are the same"); //NOI18N
+               }
+
+               // Copy all fields
+               targetBranchOffice.setBranchCity(sourceBranchOffice.getBranchCity());
+               targetBranchOffice.setBranchCompany(sourceBranchOffice.getBranchCompany());
+               targetBranchOffice.setBranchContactEmployee(sourceBranchOffice.getBranchContactEmployee());
+               targetBranchOffice.setBranchCountry(sourceBranchOffice.getBranchCountry());
+               targetBranchOffice.setBranchEmailAddress(sourceBranchOffice.getBranchEmailAddress());
+               targetBranchOffice.setBranchFaxNumber(sourceBranchOffice.getBranchFaxNumber());
+               targetBranchOffice.setBranchHouseNumber(sourceBranchOffice.getBranchHouseNumber());
+               targetBranchOffice.setBranchHouseNumberExtension(sourceBranchOffice.getBranchHouseNumberExtension());
+               targetBranchOffice.setBranchId(sourceBranchOffice.getBranchId());
+               targetBranchOffice.setBranchLandLineNumber(sourceBranchOffice.getBranchLandLineNumber());
+               targetBranchOffice.setBranchLastHouseNumber(sourceBranchOffice.getBranchLastHouseNumber());
+               targetBranchOffice.setBranchNumber(sourceBranchOffice.getBranchNumber());
+               targetBranchOffice.setBranchOpeningTimes(sourceBranchOffice.getBranchOpeningTimes());
+               targetBranchOffice.setBranchOwnerEmployee(sourceBranchOffice.getBranchOwnerEmployee());
+               targetBranchOffice.setBranchStore(sourceBranchOffice.getBranchStore());
+               targetBranchOffice.setBranchStreet(sourceBranchOffice.getBranchStreet());
+               targetBranchOffice.setBranchSuiteNumber(sourceBranchOffice.getBranchSuiteNumber());
+               targetBranchOffice.setBranchUserOwner(sourceBranchOffice.getBranchUserOwner());
+               targetBranchOffice.setBranchZipCode(sourceBranchOffice.getBranchZipCode());
+       }
+
        /**
         * Checks if both branch offices have same address. This method will throw
         * an {@code NullPointerException} if one of the instances is null.