From: Roland Häder <roland@mxchange.org>
Date: Fri, 8 Sep 2017 23:22:59 +0000 (+0200)
Subject: Continued:
X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=30c792267835be88974a4baf87e6bf770d07297e;p=jcontacts-business-core.git

Continued:
- 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>
---

diff --git a/src/org/mxchange/jcontactsbusiness/basicdata/BusinessBasicData.java b/src/org/mxchange/jcontactsbusiness/basicdata/BusinessBasicData.java
index 0314b60..3d6afe5 100644
--- a/src/org/mxchange/jcontactsbusiness/basicdata/BusinessBasicData.java
+++ b/src/org/mxchange/jcontactsbusiness/basicdata/BusinessBasicData.java
@@ -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
diff --git a/src/org/mxchange/jcontactsbusiness/basicdata/CompanyBasicData.java b/src/org/mxchange/jcontactsbusiness/basicdata/CompanyBasicData.java
index 171abd2..7d260e0 100644
--- a/src/org/mxchange/jcontactsbusiness/basicdata/CompanyBasicData.java
+++ b/src/org/mxchange/jcontactsbusiness/basicdata/CompanyBasicData.java
@@ -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());
diff --git a/src/org/mxchange/jcontactsbusiness/branchoffice/BranchOffice.java b/src/org/mxchange/jcontactsbusiness/branchoffice/BranchOffice.java
index 5690040..915847a 100644
--- a/src/org/mxchange/jcontactsbusiness/branchoffice/BranchOffice.java
+++ b/src/org/mxchange/jcontactsbusiness/branchoffice/BranchOffice.java
@@ -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
index 0000000..428ae3e
--- /dev/null
+++ b/src/org/mxchange/jcontactsbusiness/branchoffice/BranchOfficeUtils.java
@@ -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
+	}
+
+}
diff --git a/src/org/mxchange/jcontactsbusiness/branchoffice/CompanyBranchOffice.java b/src/org/mxchange/jcontactsbusiness/branchoffice/CompanyBranchOffice.java
index 691b699..93663af 100644
--- a/src/org/mxchange/jcontactsbusiness/branchoffice/CompanyBranchOffice.java
+++ b/src/org/mxchange/jcontactsbusiness/branchoffice/CompanyBranchOffice.java
@@ -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
diff --git a/src/org/mxchange/jcontactsbusiness/events/basicdata/added/AdminAddedBusinessBasicDataEvent.java b/src/org/mxchange/jcontactsbusiness/events/basicdata/added/AdminAddedBusinessBasicDataEvent.java
index 6726d65..47cb704 100644
--- a/src/org/mxchange/jcontactsbusiness/events/basicdata/added/AdminAddedBusinessBasicDataEvent.java
+++ b/src/org/mxchange/jcontactsbusiness/events/basicdata/added/AdminAddedBusinessBasicDataEvent.java
@@ -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
index 0000000..c007de3
--- /dev/null
+++ b/src/org/mxchange/jcontactsbusiness/events/branchoffice/added/BranchOfficeAddedEvent.java
@@ -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
index 0000000..23ec400
--- /dev/null
+++ b/src/org/mxchange/jcontactsbusiness/events/branchoffice/added/ObservableBranchOfficeAddedEvent.java
@@ -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 ();
+
+}
diff --git a/src/org/mxchange/jcontactsbusiness/exceptions/basicdata/BusinessDataAlreadyAddedException.java b/src/org/mxchange/jcontactsbusiness/exceptions/basicdata/BusinessDataAlreadyAddedException.java
index 4137059..dec174d 100644
--- a/src/org/mxchange/jcontactsbusiness/exceptions/basicdata/BusinessDataAlreadyAddedException.java
+++ b/src/org/mxchange/jcontactsbusiness/exceptions/basicdata/BusinessDataAlreadyAddedException.java
@@ -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
index 0000000..bfcd2b1
--- /dev/null
+++ b/src/org/mxchange/jcontactsbusiness/exceptions/branchoffice/BranchOfficeAlreadyAddedException.java
@@ -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
+	}
+
+}