]> git.mxchange.org Git - jcontacts-business-core.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Fri, 8 Sep 2017 23:22:59 +0000 (01:22 +0200)
committerRoland Häder <roland@mxchange.org>
Fri, 8 Sep 2017 23:22:59 +0000 (01:22 +0200)
- added utilities class for branch offices
- added event class/interface for branch offices being added
- added exception when a branch office has already been added
- renamed branchPhoneNumber -> branchLandLineNumber as everywhere is land-line
  used
- sorted members
- added contructor CompanyBranchOffice() with all required fields and validated
  parameters before setting them
- also need to add default constructor as the JPA requires it
- renamed companyDataId -> basicDataId

Signed-off-by: Roland Häder <roland@mxchange.org>
src/org/mxchange/jcontactsbusiness/basicdata/BusinessBasicData.java
src/org/mxchange/jcontactsbusiness/basicdata/CompanyBasicData.java
src/org/mxchange/jcontactsbusiness/branchoffice/BranchOffice.java
src/org/mxchange/jcontactsbusiness/branchoffice/BranchOfficeUtils.java [new file with mode: 0644]
src/org/mxchange/jcontactsbusiness/branchoffice/CompanyBranchOffice.java
src/org/mxchange/jcontactsbusiness/events/basicdata/added/AdminAddedBusinessBasicDataEvent.java
src/org/mxchange/jcontactsbusiness/events/branchoffice/added/BranchOfficeAddedEvent.java [new file with mode: 0644]
src/org/mxchange/jcontactsbusiness/events/branchoffice/added/ObservableBranchOfficeAddedEvent.java [new file with mode: 0644]
src/org/mxchange/jcontactsbusiness/exceptions/basicdata/BusinessDataAlreadyAddedException.java
src/org/mxchange/jcontactsbusiness/exceptions/branchoffice/BranchOfficeAlreadyAddedException.java [new file with mode: 0644]

index 0314b60eb64ba0b49e137eac201037806b621ca3..3d6afe5df3d648aae25bfb0f93142e2d80164a2f 100644 (file)
@@ -67,14 +67,14 @@ public interface BusinessBasicData extends Serializable {
         * <p>
         * @return Business contact id
         */
-       Long getCompanyDataId ();
+       Long getBasicDataId ();
 
        /**
         * Setter for business contact id
         * <p>
         * @param businessContactId Business contact id
         */
-       void setCompanyDataId (final Long businessContactId);
+       void setBasicDataId (final Long businessContactId);
 
        /**
         * Getter for company founder
index 171abd247b4374f7c87f93ae0d7c8fd1b7928fe2..7d260e0070c4efdfae7d75a0deba8834d2d5b487 100644 (file)
@@ -58,8 +58,8 @@ import org.mxchange.jusercore.model.user.User;
 @Table (name = "company_basic_data")
 @NamedQueries (
                {
-                       @NamedQuery (name = "AllBusinessData", query = "SELECT b FROM company_basic_data AS b ORDER BY b.companyDataId"),
-                       @NamedQuery (name = "SearchBusinessDataById", query = "SELECT b FROM company_basic_data AS b WHERE b.companyDataId = :companyDataId")
+                       @NamedQuery (name = "AllBusinessData", query = "SELECT b FROM company_basic_data AS b ORDER BY b.basicDataId"),
+                       @NamedQuery (name = "SearchBusinessDataById", query = "SELECT b FROM company_basic_data AS b WHERE b.basicDataId = :basicDataId")
                }
 )
 @SuppressWarnings ("PersistenceUnitPresent")
@@ -71,6 +71,14 @@ public class CompanyBasicData implements BusinessBasicData {
        @Transient
        private static final long serialVersionUID = 470_375_172_748_691L;
 
+       /**
+        * Id number
+        */
+       @Id
+       @Column (name = "company_data_id", nullable = false, updatable = false)
+       @GeneratedValue (strategy = GenerationType.IDENTITY)
+       private Long basicDataId;
+
        /**
         * Reference to company branch offices
         */
@@ -99,14 +107,6 @@ public class CompanyBasicData implements BusinessBasicData {
        @Column (name = "company_entry_created", nullable = false, updatable = false)
        private Calendar companyCreated;
 
-       /**
-        * Id number
-        */
-       @Id
-       @Column (name = "company_data_id", nullable = false, updatable = false)
-       @GeneratedValue (strategy = GenerationType.IDENTITY)
-       private Long companyDataId;
-
        /**
         * Company's main email address (example: info@company.com)
         */
@@ -209,7 +209,7 @@ public class CompanyBasicData implements BusinessBasicData {
 
                final BusinessBasicData other = (BusinessBasicData) object;
 
-               if (!Objects.equals(this.getCompanyDataId(), other.getCompanyDataId())) {
+               if (!Objects.equals(this.getBasicDataId(), other.getBasicDataId())) {
                        return false;
                } else if (!Objects.equals(this.getCompanyName(), other.getCompanyName())) {
                        return false;
@@ -224,6 +224,16 @@ public class CompanyBasicData implements BusinessBasicData {
                return true;
        }
 
+       @Override
+       public Long getBasicDataId () {
+               return this.basicDataId;
+       }
+
+       @Override
+       public void setBasicDataId (final Long basicDataId) {
+               this.basicDataId = basicDataId;
+       }
+
        @Override
        @SuppressWarnings ("ReturnOfCollectionOrArrayField")
        public List<BranchOffice> getBrancheOffices () {
@@ -268,16 +278,6 @@ public class CompanyBasicData implements BusinessBasicData {
                this.companyCreated = companyCreated;
        }
 
-       @Override
-       public Long getCompanyDataId () {
-               return this.companyDataId;
-       }
-
-       @Override
-       public void setCompanyDataId (final Long companyDataId) {
-               this.companyDataId = companyDataId;
-       }
-
        @Override
        public String getCompanyEmailAddress () {
                return this.companyEmailAddress;
@@ -382,7 +382,7 @@ public class CompanyBasicData implements BusinessBasicData {
        public int hashCode () {
                int hash = 3;
 
-               hash = 37 * hash + Objects.hashCode(this.getCompanyDataId());
+               hash = 37 * hash + Objects.hashCode(this.getBasicDataId());
                hash = 37 * hash + Objects.hashCode(this.getCompanyName());
                hash = 37 * hash + Objects.hashCode(this.getCompanyHeadQuartersData());
                hash = 37 * hash + Objects.hashCode(this.getCompanyContactEmployee());
index 56900403c1269ec77bae56a2ffe09b8c0766a3a9..915847ad68a50db213b6dac9b65236be86e58ec5 100644 (file)
@@ -93,14 +93,14 @@ public interface BranchOffice extends Serializable {
         * <p>
         * @return Branch office's phone number
         */
-       DialableLandLineNumber getBranchPhoneNumber ();
+       DialableLandLineNumber getBranchLandLineNumber ();
 
        /**
         * Setter for branch office's phone number
         * <p>
         * @param branchPhoneNumber Branch office's phone number
         */
-       void setBranchPhoneNumber (final DialableLandLineNumber branchPhoneNumber);
+       void setBranchLandLineNumber (final DialableLandLineNumber branchPhoneNumber);
 
        /**
         * Getter for branch office's store
diff --git a/src/org/mxchange/jcontactsbusiness/branchoffice/BranchOfficeUtils.java b/src/org/mxchange/jcontactsbusiness/branchoffice/BranchOfficeUtils.java
new file mode 100644 (file)
index 0000000..428ae3e
--- /dev/null
@@ -0,0 +1,96 @@
+/*
+ * 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.jcontactsbusiness.branchoffice;
+
+import java.io.Serializable;
+import java.util.Objects;
+
+/**
+ * An utilities class for branch offices
+ *
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public class BranchOfficeUtils implements Serializable {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 69_537_867_224_651L;
+
+       /**
+        * Checks if both branch offices have same address. This method will throw
+        * an {@code NullPointerException} if one of the instances is null.
+        * <p>
+        * @param branchOffice1 Branch office 1
+        * @param branchOffice2 Branch office 2
+        * <p>
+        * @return Whether both branch office addresses are the same
+        * <p>
+        * @throws NullPointerException If one of the instances is null
+        */
+       public static boolean isSameAddress (final BranchOffice branchOffice1, final BranchOffice branchOffice2) {
+               // Check that both parameters are not null
+               if (null == branchOffice1) {
+                       // Throw NPE
+                       throw new NullPointerException("branchOffice1 is null"); //NOI18N
+               } else if (null == branchOffice2) {
+                       // Throw NPE
+                       throw new NullPointerException("branchOffice2 is null"); //NOI18N
+               }
+
+               // Default is the same
+               boolean isSameAddress = true;
+
+               // Compare both addresses
+               if (!Objects.equals(branchOffice1.getBranchCompany(), branchOffice2.getBranchCompany())) {
+                       // Not the same
+                       isSameAddress = false;
+               } else if (!Objects.equals(branchOffice1.getBranchCountry(), branchOffice2.getBranchCountry())) {
+                       // Not the same
+                       isSameAddress = false;
+               } else if (!Objects.equals(branchOffice1.getBranchCity(), branchOffice2.getBranchCity())) {
+                       // Not the same
+                       isSameAddress = false;
+               } else if (!Objects.equals(branchOffice1.getBranchZipCode(), branchOffice2.getBranchZipCode())) {
+                       // Not the same
+                       isSameAddress = false;
+               } else if (!Objects.equals(branchOffice1.getBranchStreet(), branchOffice2.getBranchStreet())) {
+                       // Not the same
+                       isSameAddress = false;
+               } else if (!Objects.equals(branchOffice1.getBranchHouseNumber(), branchOffice2.getBranchHouseNumber())) {
+                       // Not the same
+                       isSameAddress = false;
+               } else if (!Objects.equals(branchOffice1.getBranchStore(), branchOffice2.getBranchStore())) {
+                       // Not the same
+                       isSameAddress = false;
+               } else if (!Objects.equals(branchOffice1.getBranchSuiteNumber(), branchOffice2.getBranchSuiteNumber())) {
+                       // Not the same
+                       isSameAddress = false;
+               }
+
+               // Return flag
+               return isSameAddress;
+       }
+
+       /**
+        * Private default constructor
+        */
+       private BranchOfficeUtils () {
+               // Utilities don't have instances
+       }
+
+}
index 691b69915376ac80d6e90317f596b0f2adb85c8b..93663afc5933a48d945e06c15c8af87d94d0e202 100644 (file)
@@ -16,6 +16,7 @@
  */
 package org.mxchange.jcontactsbusiness.branchoffice;
 
+import java.text.MessageFormat;
 import java.util.Calendar;
 import java.util.Objects;
 import javax.persistence.Basic;
@@ -76,9 +77,16 @@ public class CompanyBranchOffice implements BranchOffice {
         * Company that has this branch office
         */
        @JoinColumn (name = "branch_company_id", nullable = false, updatable = false)
-       @OneToOne (targetEntity = CompanyBasicData.class, optional = false, cascade = CascadeType.ALL)
+       @OneToOne (targetEntity = CompanyBasicData.class, optional = false, cascade = CascadeType.REFRESH)
        private BusinessBasicData branchCompany;
 
+       /**
+        * Reference to contact person
+        */
+       @JoinColumn (name = "branch_contact_employee_id")
+       @OneToOne (targetEntity = CompanyEmployee.class, cascade = CascadeType.REFRESH)
+       private Employee branchContactEmployee;
+
        /**
         * Branch office's country code
         */
@@ -100,13 +108,6 @@ public class CompanyBranchOffice implements BranchOffice {
        @Column (name = "branch_email_address", length = 100)
        private String branchEmailAddress;
 
-       /**
-        * Reference to contact person
-        */
-       @JoinColumn (name = "branch_contact_employee_id")
-       @OneToOne (targetEntity = CompanyEmployee.class, cascade = CascadeType.ALL)
-       private Employee branchContactEmployee;
-
        /**
         * Branch office's main fax number: +ccxxxxxxxxxx
         */
@@ -130,11 +131,11 @@ public class CompanyBranchOffice implements BranchOffice {
        private Long branchId;
 
        /**
-        * Branch office's main phone number: +ccxxxxxxxxxx
+        * Branch office's main land-line number: +ccxxxxxxxxxx
         */
-       @JoinColumn (name = "branch_phone_number_id")
+       @JoinColumn (name = "branch_landline_number_id")
        @OneToOne (targetEntity = LandLineNumber.class, cascade = CascadeType.ALL)
-       private DialableLandLineNumber branchPhoneNumber;
+       private DialableLandLineNumber branchLandLineNumber;
 
        /**
         * Branch office's store (if multiple-store building)
@@ -169,6 +170,81 @@ public class CompanyBranchOffice implements BranchOffice {
        @Column (name = "branch_zip_code", length = 6, nullable = false)
        private Integer branchZipCode;
 
+       /**
+        * Default constructor for JPA
+        */
+       public CompanyBranchOffice () {
+       }
+
+       /**
+        * Constructor with all required fields. This constructor may throw
+        * exceptions when one parameter is not valid or NULL.
+        * <p>
+        * @param branchCity         Branch office's city
+        * @param branchCompany      Branch office's assigned company
+        * @param branchCountry      Branch office's country
+        * @param branchStreet       Branch office's street
+        * @param branchZipCode      Branch office's ZIP code
+        * @param branchHouseNumber Branch office's house number
+        */
+       public CompanyBranchOffice (final String branchCity, final BusinessBasicData branchCompany, final Country branchCountry, final String branchStreet, final Integer branchZipCode, final Short branchHouseNumber) {
+               // Call other constructor
+               this();
+
+               // Check all parameter
+               if (null == branchCity) {
+                       // Throw NPE
+                       throw new NullPointerException("branchCity is null"); //NOI18N
+               } else if (branchCity.isEmpty()) {
+                       // Throw IAE
+                       throw new IllegalArgumentException("branchCity is empty"); //NOI18N
+               } else if (null == branchCompany) {
+                       // Throw NPE
+                       throw new NullPointerException("branchCompany is null"); //NOI18N
+               } else if (branchCompany.getBasicDataId() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("branchCompany.basicDataId is null"); //NOI18N
+               } else if (branchCompany.getBasicDataId() < 1) {
+                       // Throw IAE again
+                       throw new IllegalArgumentException(MessageFormat.format("branchCompany.basicDataId={0} is invalid", branchCompany.getBasicDataId())); //NOI18N
+               } else if (null == branchCountry) {
+                       // Throw NPE again
+                       throw new NullPointerException("branchCountry is null"); //NOI18N
+               } else if (branchCountry.getCountryId() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("branchCountry.countryId is null"); //NOI18N
+               } else if (branchCountry.getCountryId() < 1) {
+                       // Throw IAE again
+                       throw new IllegalArgumentException(MessageFormat.format("branchCountry.countryId={0} is invalid", branchCountry.getCountryId())); //NOI18N
+               } else if (null == branchStreet) {
+                       // Throw NPE
+                       throw new NullPointerException("branchStreet is null"); //NOI18N
+               } else if (branchStreet.isEmpty()) {
+                       // Throw IAE
+                       throw new IllegalArgumentException("branchStreet is empty"); //NOI18N
+               } else if (null == branchZipCode) {
+                       // Throw NPE
+                       throw new NullPointerException("branchZipCode is null"); //NOI18N
+               } else if (branchZipCode < 1) {
+                       // Throw IAE
+                       throw new IllegalArgumentException(MessageFormat.format("branchZipCode={0} is out of range.", branchZipCode)); //NOI18N
+               } else if (null == branchHouseNumber) {
+                       // Throw NPE
+                       throw new NullPointerException("branchHouseNumber is null"); //NOI18N
+               } else if (branchHouseNumber < 1) {
+                       // Throw IAE
+                       throw new IllegalArgumentException(MessageFormat.format("branchHouseNumber={0} is out of range.", branchHouseNumber)); //NOI18N
+               }
+
+               // Set all fields
+               this.branchCity = branchCity;
+               this.branchCompany = branchCompany;
+               this.branchCountry = branchCountry;
+               this.branchStreet = branchStreet;
+               this.branchZipCode = branchZipCode;
+               this.branchHouseNumber = branchHouseNumber;
+       }
+
        @Override
        public boolean equals (final Object object) {
                if (null == object) {
@@ -220,6 +296,16 @@ public class CompanyBranchOffice implements BranchOffice {
                this.branchCompany = branchCompany;
        }
 
+       @Override
+       public Employee getBranchContactEmployee () {
+               return this.branchContactEmployee;
+       }
+
+       @Override
+       public void setBranchContactEmployee (final Employee branchContactEmployee) {
+               this.branchContactEmployee = branchContactEmployee;
+       }
+
        @Override
        public Country getBranchCountry () {
                return this.branchCountry;
@@ -252,16 +338,6 @@ public class CompanyBranchOffice implements BranchOffice {
                this.branchEmailAddress = branchEmailAddress;
        }
 
-       @Override
-       public Employee getBranchContactEmployee () {
-               return this.branchContactEmployee;
-       }
-
-       @Override
-       public void setBranchContactEmployee (final Employee branchContactEmployee) {
-               this.branchContactEmployee = branchContactEmployee;
-       }
-
        @Override
        public DialableFaxNumber getBranchFaxNumber () {
                return this.branchFaxNumber;
@@ -293,13 +369,13 @@ public class CompanyBranchOffice implements BranchOffice {
        }
 
        @Override
-       public DialableLandLineNumber getBranchPhoneNumber () {
-               return this.branchPhoneNumber;
+       public DialableLandLineNumber getBranchLandLineNumber () {
+               return this.branchLandLineNumber;
        }
 
        @Override
-       public void setBranchPhoneNumber (final DialableLandLineNumber branchPhoneNumber) {
-               this.branchPhoneNumber = branchPhoneNumber;
+       public void setBranchLandLineNumber (final DialableLandLineNumber branchLandLineNumber) {
+               this.branchLandLineNumber = branchLandLineNumber;
        }
 
        @Override
index 6726d650a6dcb0224bc3e8c110b689fe8c46f71d..47cb704229d52fd42717cfe3e76a0b724975fe2e 100644 (file)
@@ -53,12 +53,12 @@ public class AdminAddedBusinessBasicDataEvent implements ObservableAdminAddedBus
                } else if (basicData.getCompanyName().isEmpty()) {
                        // Throw NPE again
                        throw new IllegalArgumentException("basicData.companyName is empty"); //NOI18N
-               } else if (basicData.getCompanyDataId() == null) {
+               } else if (basicData.getBasicDataId() == null) {
                        // Throw NPE again
-                       throw new NullPointerException("basicData.companyDataId is null"); //NOI18N
-               } else if (basicData.getCompanyDataId() < 1) {
+                       throw new NullPointerException("basicData.basicDataId is null"); //NOI18N
+               } else if (basicData.getBasicDataId() < 1) {
                        // Throw NPE again
-                       throw new IllegalArgumentException(MessageFormat.format("basicData.companyDataId={0} is not valid.", basicData.getCompanyDataId())); //NOI18N
+                       throw new IllegalArgumentException(MessageFormat.format("basicData.basicDataId={0} is not valid.", basicData.getBasicDataId())); //NOI18N
                }
 
                // Set it here
diff --git a/src/org/mxchange/jcontactsbusiness/events/branchoffice/added/BranchOfficeAddedEvent.java b/src/org/mxchange/jcontactsbusiness/events/branchoffice/added/BranchOfficeAddedEvent.java
new file mode 100644 (file)
index 0000000..c007de3
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * 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.jcontactsbusiness.events.branchoffice.added;
+
+import java.text.MessageFormat;
+import org.mxchange.jcontactsbusiness.branchoffice.BranchOffice;
+
+/**
+ * An event being fired when a branch office has been added
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public class BranchOfficeAddedEvent implements ObservableBranchOfficeAddedEvent {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 572_367_561_659_109L;
+
+       /**
+        * Branch office instance being added
+        */
+       private final BranchOffice branchOffice;
+
+       /**
+        * Constructor with branch office instance
+        * <p>
+        * @param branchOffice Branch office instance
+        * @throws NullPointerException If the parameter is null
+        */
+       public BranchOfficeAddedEvent (final BranchOffice branchOffice) {
+               // Check parameter
+               if (null == branchOffice) {
+                       // Throw NPE
+                       throw new NullPointerException("branchOffice is null"); //NOI18N
+               } else if (branchOffice.getBranchId() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("branchOffice.branchId is null"); //NOI18N
+               } else if (branchOffice.getBranchId() < 1) {
+                       // Throw NPE again
+                       throw new NullPointerException(MessageFormat.format("branchOffice.branchId={0} is not valid", branchOffice.getBranchId())); //NOI18N
+               }
+
+               // Set it
+               this.branchOffice = branchOffice;
+       }
+
+       @Override
+       public BranchOffice getBranchOffice () {
+               return this.branchOffice;
+       }
+
+}
diff --git a/src/org/mxchange/jcontactsbusiness/events/branchoffice/added/ObservableBranchOfficeAddedEvent.java b/src/org/mxchange/jcontactsbusiness/events/branchoffice/added/ObservableBranchOfficeAddedEvent.java
new file mode 100644 (file)
index 0000000..23ec400
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * 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.jcontactsbusiness.events.branchoffice.added;
+
+import java.io.Serializable;
+import org.mxchange.jcontactsbusiness.branchoffice.BranchOffice;
+
+/**
+ * An interface for events being triggered when a branch office has been added.
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface ObservableBranchOfficeAddedEvent extends Serializable {
+
+       /**
+        * Getter for branch office instance
+        * <p>
+        * @return Branch office instance
+        */
+       BranchOffice getBranchOffice ();
+
+}
index 413705977c838c612e38cfa7c0d93afb7f4a6082..dec174d1e4b50d0a75de52c2a1efc8518faf963d 100644 (file)
@@ -32,7 +32,7 @@ public class BusinessDataAlreadyAddedException extends Exception {
        private static final long serialVersionUID = 75_844_851_467L;
 
        /**
-        * Constructor with a Contact instance
+        * Constructor with a basic data instance
         * <p>
         * @param businessContact Business contact that is already added
         */
diff --git a/src/org/mxchange/jcontactsbusiness/exceptions/branchoffice/BranchOfficeAlreadyAddedException.java b/src/org/mxchange/jcontactsbusiness/exceptions/branchoffice/BranchOfficeAlreadyAddedException.java
new file mode 100644 (file)
index 0000000..bfcd2b1
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * 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.jcontactsbusiness.exceptions.branchoffice;
+
+import java.text.MessageFormat;
+import org.mxchange.jcontactsbusiness.branchoffice.BranchOffice;
+
+/**
+ * Thrown if the given BusinessBasicData instance is already added
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public class BranchOfficeAlreadyAddedException extends Exception {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 75_844_851_467L;
+
+       /**
+        * Constructor with a branch office instance
+        * <p>
+        * @param branchOffice Branch office that is already found
+        */
+       public BranchOfficeAlreadyAddedException (final BranchOffice branchOffice) {
+               super(MessageFormat.format("Branch office with branchStreet={0},branchHouseNumber={1},branchZipCode={2},branchCity={3} already created.", branchOffice.getBranchStreet(), branchOffice.getBranchHouseNumber(), branchOffice.getBranchZipCode(), branchOffice.getBranchCity()));
+       }
+
+       /**
+        * Default constructor, may be used if no contact instance is available
+        */
+       public BranchOfficeAlreadyAddedException () {
+               super("Branch office already added"); //NOI18N
+       }
+
+}