From: Roland Häder Date: Thu, 2 Nov 2017 19:45:12 +0000 (+0100) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=077150bcd85617517c5439794e899a32b554cf82;p=jcontacts-business-core.git Continued: - renamed all occurrences of headquarters to headquarter as it was confusing on many places, if singular or plural was used. Only Headquarters for utilities class remain (surely). Signed-off-by: Roland Häder --- diff --git a/src/org/mxchange/jcontactsbusiness/events/headquarter/added/HeadquarterAddedEvent.java b/src/org/mxchange/jcontactsbusiness/events/headquarter/added/HeadquarterAddedEvent.java new file mode 100644 index 0000000..ed948f1 --- /dev/null +++ b/src/org/mxchange/jcontactsbusiness/events/headquarter/added/HeadquarterAddedEvent.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 . + */ +package org.mxchange.jcontactsbusiness.events.headquarter.added; + +import java.text.MessageFormat; +import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter; + +/** + * An event being fired when a branch office has been added + *

+ * @author Roland Häder + */ +public class HeadquarterAddedEvent implements ObservableHeadquarterAddedEvent { + + /** + * Serial number + */ + private static final long serialVersionUID = 572_367_561_659_110L; + + /** + * Headquarter office instance being added + */ + private final Headquarter headquarter; + + /** + * Constructor with branch office instance + *

+ * @param headquarter Headquarter office instance + * @throws NullPointerException If the parameter is null + */ + public HeadquarterAddedEvent (final Headquarter headquarter) { + // Check parameter + if (null == headquarter) { + // Throw NPE + throw new NullPointerException("headquarter is null"); //NOI18N + } else if (headquarter.getHeadquarterId() == null) { + // Throw NPE again + throw new NullPointerException("headquarter.headquarterId is null"); //NOI18N + } else if (headquarter.getHeadquarterId() < 1) { + // Throw NPE again + throw new NullPointerException(MessageFormat.format("headquarter.headquarterId={0} is not valid", headquarter.getHeadquarterId())); //NOI18N + } + + // Set it + this.headquarter = headquarter; + } + + @Override + public Headquarter getHeadquarter () { + return this.headquarter; + } + +} diff --git a/src/org/mxchange/jcontactsbusiness/events/headquarter/added/ObservableHeadquarterAddedEvent.java b/src/org/mxchange/jcontactsbusiness/events/headquarter/added/ObservableHeadquarterAddedEvent.java new file mode 100644 index 0000000..c014d5f --- /dev/null +++ b/src/org/mxchange/jcontactsbusiness/events/headquarter/added/ObservableHeadquarterAddedEvent.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 . + */ +package org.mxchange.jcontactsbusiness.events.headquarter.added; + +import java.io.Serializable; +import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter; + +/** + * An interface for events being triggered when a headquarter has been added. + *

+ * @author Roland Häder + */ +public interface ObservableHeadquarterAddedEvent extends Serializable { + + /** + * Getter for headquarter instance + *

+ * @return Headquarter instance + */ + Headquarter getHeadquarter (); + +} diff --git a/src/org/mxchange/jcontactsbusiness/events/headquarters/added/HeadquartersAddedEvent.java b/src/org/mxchange/jcontactsbusiness/events/headquarters/added/HeadquartersAddedEvent.java deleted file mode 100644 index d03f1e1..0000000 --- a/src/org/mxchange/jcontactsbusiness/events/headquarters/added/HeadquartersAddedEvent.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * 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 . - */ -package org.mxchange.jcontactsbusiness.events.headquarters.added; - -import java.text.MessageFormat; -import org.mxchange.jcontactsbusiness.model.headquarters.Headquarter; - -/** - * An event being fired when a branch office has been added - *

- * @author Roland Häder - */ -public class HeadquartersAddedEvent implements ObservableHeadquartersAddedEvent { - - /** - * Serial number - */ - private static final long serialVersionUID = 572_367_561_659_110L; - - /** - * Headquarters office instance being added - */ - private final Headquarter headquarters; - - /** - * Constructor with branch office instance - *

- * @param headquarters Headquarters office instance - * @throws NullPointerException If the parameter is null - */ - public HeadquartersAddedEvent (final Headquarter headquarters) { - // Check parameter - if (null == headquarters) { - // Throw NPE - throw new NullPointerException("headquarters is null"); //NOI18N - } else if (headquarters.getHeadquartersId() == null) { - // Throw NPE again - throw new NullPointerException("headquarters.headquartersId is null"); //NOI18N - } else if (headquarters.getHeadquartersId() < 1) { - // Throw NPE again - throw new NullPointerException(MessageFormat.format("headquarters.headquartersId={0} is not valid", headquarters.getHeadquartersId())); //NOI18N - } - - // Set it - this.headquarters = headquarters; - } - - @Override - public Headquarter getHeadquarters () { - return this.headquarters; - } - -} diff --git a/src/org/mxchange/jcontactsbusiness/events/headquarters/added/ObservableHeadquartersAddedEvent.java b/src/org/mxchange/jcontactsbusiness/events/headquarters/added/ObservableHeadquartersAddedEvent.java deleted file mode 100644 index 7cacdc3..0000000 --- a/src/org/mxchange/jcontactsbusiness/events/headquarters/added/ObservableHeadquartersAddedEvent.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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 . - */ -package org.mxchange.jcontactsbusiness.events.headquarters.added; - -import java.io.Serializable; -import org.mxchange.jcontactsbusiness.model.headquarters.Headquarter; - -/** - * An interface for events being triggered when a headquarters has been added. - *

- * @author Roland Häder - */ -public interface ObservableHeadquartersAddedEvent extends Serializable { - - /** - * Getter for headquarters instance - *

- * @return Headquarters instance - */ - Headquarter getHeadquarters (); - -} diff --git a/src/org/mxchange/jcontactsbusiness/exceptions/headquarter/HeadquarterAlreadyAddedException.java b/src/org/mxchange/jcontactsbusiness/exceptions/headquarter/HeadquarterAlreadyAddedException.java new file mode 100644 index 0000000..41629c1 --- /dev/null +++ b/src/org/mxchange/jcontactsbusiness/exceptions/headquarter/HeadquarterAlreadyAddedException.java @@ -0,0 +1,43 @@ +/* + * 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 . + */ +package org.mxchange.jcontactsbusiness.exceptions.headquarter; + +import java.text.MessageFormat; +import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter; + +/** + * An exception thrown when a headquarter (entity) was already added. + *

+ * @author Roland Häder + */ +public class HeadquarterAlreadyAddedException extends Exception { + + /** + * Serial number + */ + private static final long serialVersionUID = 23_759_801_876_416_573L; + + /** + * Constructor with a headquarter instance + *

+ * @param headquarter Headquarter that is already found + */ + public HeadquarterAlreadyAddedException (final Headquarter headquarter) { + super(MessageFormat.format("Headquarter with headquarterStreet={0},headquarterHouseNumber={1},headquarterZipCode={2},headquarterCity={3} already created.", headquarter.getHeadquarterStreet(), headquarter.getHeadquarterHouseNumber(), headquarter.getHeadquarterZipCode(), headquarter.getHeadquarterCity())); + } + +} diff --git a/src/org/mxchange/jcontactsbusiness/exceptions/headquarter/HeadquarterNotFoundException.java b/src/org/mxchange/jcontactsbusiness/exceptions/headquarter/HeadquarterNotFoundException.java new file mode 100644 index 0000000..f2982e6 --- /dev/null +++ b/src/org/mxchange/jcontactsbusiness/exceptions/headquarter/HeadquarterNotFoundException.java @@ -0,0 +1,65 @@ +/* + * 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 . + */ +package org.mxchange.jcontactsbusiness.exceptions.headquarter; + +import java.text.MessageFormat; + +/** + * An exception thrown when a headquarter (entity) has not found. + *

+ * @author Roland Häder + */ +public class HeadquarterNotFoundException extends Exception { + + /** + * Serial number + */ + private static final long serialVersionUID = 23_759_801_876_416_572L; + + /** + * Constructor with company headquarter id + *

+ * @param headquarterId Company headquarter id + */ + public HeadquarterNotFoundException (final Long headquarterId) { + // Call super constructor with message and cause + super(MessageFormat.format("Company headquarter with id {0} was not found.", headquarterId)); //NOI18N + } + + /** + * Constructor with company headquarter id and causing exception + *

+ * @param headquarterId Company headquarter id + * @param cause Causing exception + */ + public HeadquarterNotFoundException (final Long headquarterId, final Throwable cause) { + // Call super constructor with message and cause + super(MessageFormat.format("Company headquarter with id {0} was not found.", headquarterId), cause); //NOI18N + } + + /** + * Constructor with email address and causing exception + *

+ * @param emailAddress Email address + * @param cause Causing exception + */ + public HeadquarterNotFoundException (final String emailAddress, final Throwable cause) { + // Call super constructor with message and cause + super(MessageFormat.format("Company headquarter with email address {0} was not found.", emailAddress), cause); //NOI18N + } + +} diff --git a/src/org/mxchange/jcontactsbusiness/exceptions/headquarters/HeadquartersAlreadyAddedException.java b/src/org/mxchange/jcontactsbusiness/exceptions/headquarters/HeadquartersAlreadyAddedException.java deleted file mode 100644 index 25a5470..0000000 --- a/src/org/mxchange/jcontactsbusiness/exceptions/headquarters/HeadquartersAlreadyAddedException.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 . - */ -package org.mxchange.jcontactsbusiness.exceptions.headquarters; - -import java.text.MessageFormat; -import org.mxchange.jcontactsbusiness.model.headquarters.Headquarter; - -/** - * An exception thrown when a headquarters (entity) was already added. - *

- * @author Roland Häder - */ -public class HeadquartersAlreadyAddedException extends Exception { - - /** - * Serial number - */ - private static final long serialVersionUID = 23_759_801_876_416_573L; - - /** - * Constructor with a headquarters instance - *

- * @param headquarters Headquarter that is already found - */ - public HeadquartersAlreadyAddedException (final Headquarter headquarters) { - super(MessageFormat.format("Headquarters office with headquartersStreet={0},headquartersHouseNumber={1},headquartersZipCode={2},headquartersCity={3} already created.", headquarters.getHeadquartersStreet(), headquarters.getHeadquartersHouseNumber(), headquarters.getHeadquartersZipCode(), headquarters.getHeadquartersCity())); - } - -} diff --git a/src/org/mxchange/jcontactsbusiness/exceptions/headquarters/HeadquartersNotFoundException.java b/src/org/mxchange/jcontactsbusiness/exceptions/headquarters/HeadquartersNotFoundException.java deleted file mode 100644 index 514d1fa..0000000 --- a/src/org/mxchange/jcontactsbusiness/exceptions/headquarters/HeadquartersNotFoundException.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * 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 . - */ -package org.mxchange.jcontactsbusiness.exceptions.headquarters; - -import java.text.MessageFormat; - -/** - * An exception thrown when a headquarters (entity) has not found. - *

- * @author Roland Häder - */ -public class HeadquartersNotFoundException extends Exception { - - /** - * Serial number - */ - private static final long serialVersionUID = 23_759_801_876_416_572L; - - /** - * Constructor with company headquarters id - *

- * @param headquartersId Company headquarters id - */ - public HeadquartersNotFoundException (final Long headquartersId) { - // Call super constructor with message and cause - super(MessageFormat.format("Company headquarters with id {0} was not found.", headquartersId)); //NOI18N - } - - /** - * Constructor with company headquarters id and causing exception - *

- * @param headquartersId Company headquarters id - * @param cause Causing exception - */ - public HeadquartersNotFoundException (final Long headquartersId, final Throwable cause) { - // Call super constructor with message and cause - super(MessageFormat.format("Company headquarters with id {0} was not found.", headquartersId), cause); //NOI18N - } - - /** - * Constructor with email address and causing exception - *

- * @param emailAddress Email address - * @param cause Causing exception - */ - public HeadquartersNotFoundException (final String emailAddress, final Throwable cause) { - // Call super constructor with message and cause - super(MessageFormat.format("Company headquarters with email address {0} was not found.", emailAddress), cause); //NOI18N - } - -} diff --git a/src/org/mxchange/jcontactsbusiness/model/basicdata/BasicData.java b/src/org/mxchange/jcontactsbusiness/model/basicdata/BasicData.java index ff170c6..9b00467 100644 --- a/src/org/mxchange/jcontactsbusiness/model/basicdata/BasicData.java +++ b/src/org/mxchange/jcontactsbusiness/model/basicdata/BasicData.java @@ -25,7 +25,7 @@ import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber; import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber; import org.mxchange.jusercore.model.user.User; import org.mxchange.jcontactsbusiness.model.logo.Logo; -import org.mxchange.jcontactsbusiness.model.headquarters.Headquarter; +import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter; /** * A POJI for business contact classes @@ -91,18 +91,18 @@ public interface BasicData extends Serializable { void setCompanyFounder (final Employable companyFounder); /** - * Getter for headquarters data + * Getter for headquarter data *

* @return Headquarter data */ - Headquarter getCompanyHeadQuartersData (); + Headquarter getCompanyHeadquarterData (); /** - * Setter for headquarters data + * Setter for headquarter data *

* @param headQuartersData Headquarter data */ - void setCompanyHeadQuartersData (final Headquarter headQuartersData); + void setCompanyHeadquarterData (final Headquarter headQuartersData); /** * Getter for user owner instance diff --git a/src/org/mxchange/jcontactsbusiness/model/basicdata/BusinessBasicData.java b/src/org/mxchange/jcontactsbusiness/model/basicdata/BusinessBasicData.java index 88b5fca..43be826 100644 --- a/src/org/mxchange/jcontactsbusiness/model/basicdata/BusinessBasicData.java +++ b/src/org/mxchange/jcontactsbusiness/model/basicdata/BusinessBasicData.java @@ -38,8 +38,8 @@ import javax.persistence.Transient; import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice; import org.mxchange.jcontactsbusiness.model.employee.BusinessEmployee; import org.mxchange.jcontactsbusiness.model.employee.Employable; -import org.mxchange.jcontactsbusiness.model.headquarters.BusinessHeadquarters; -import org.mxchange.jcontactsbusiness.model.headquarters.Headquarter; +import org.mxchange.jcontactsbusiness.model.headquarter.BusinessHeadquarter; +import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter; import org.mxchange.jcontactsbusiness.model.logo.BusinessLogo; import org.mxchange.jcontactsbusiness.model.logo.Logo; import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber; @@ -127,11 +127,11 @@ public class BusinessBasicData implements BasicData { private Employable companyFounder; /** - * Reference to headquarters data + * Reference to headquarter data */ - @JoinColumn (name = "company_headquarters_data_id") - @OneToOne (targetEntity = BusinessHeadquarters.class, cascade = CascadeType.ALL) - private Headquarter companyHeadQuartersData; + @JoinColumn (name = "company_headquarter_data_id") + @OneToOne (targetEntity = BusinessHeadquarter.class, cascade = CascadeType.ALL) + private Headquarter companyHeadquarterData; /** * Company's main phone number: +ccxxxxxxxxxx @@ -212,7 +212,7 @@ public class BusinessBasicData implements BasicData { return false; } else if (!Objects.equals(this.getCompanyName(), other.getCompanyName())) { return false; - } else if (!Objects.equals(this.getCompanyHeadQuartersData(), other.getCompanyHeadQuartersData())) { + } else if (!Objects.equals(this.getCompanyHeadquarterData(), other.getCompanyHeadquarterData())) { return false; } else if (!Objects.equals(this.getCompanyContactEmployee(), other.getCompanyContactEmployee())) { return false; @@ -308,13 +308,13 @@ public class BusinessBasicData implements BasicData { } @Override - public Headquarter getCompanyHeadQuartersData () { - return this.companyHeadQuartersData; + public Headquarter getCompanyHeadquarterData () { + return this.companyHeadquarterData; } @Override - public void setCompanyHeadQuartersData (final Headquarter companyHeadQuartersData) { - this.companyHeadQuartersData = companyHeadQuartersData; + public void setCompanyHeadquarterData (final Headquarter companyHeadquarterData) { + this.companyHeadquarterData = companyHeadquarterData; } @Override @@ -383,7 +383,7 @@ public class BusinessBasicData implements BasicData { 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.getCompanyHeadquarterData()); hash = 37 * hash + Objects.hashCode(this.getCompanyContactEmployee()); hash = 37 * hash + Objects.hashCode(this.getCompanyFounder()); diff --git a/src/org/mxchange/jcontactsbusiness/model/department/BusinessDepartment.java b/src/org/mxchange/jcontactsbusiness/model/department/BusinessDepartment.java index df247c5..0f90dd7 100644 --- a/src/org/mxchange/jcontactsbusiness/model/department/BusinessDepartment.java +++ b/src/org/mxchange/jcontactsbusiness/model/department/BusinessDepartment.java @@ -38,12 +38,12 @@ import org.mxchange.jcontactsbusiness.model.basicdata.BusinessBasicData; import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice; import org.mxchange.jcontactsbusiness.model.branchoffice.BusinessBranchOffice; import org.mxchange.jcontactsbusiness.model.employee.BusinessEmployee; -import org.mxchange.jcontactsbusiness.model.headquarters.BusinessHeadquarters; +import org.mxchange.jcontactsbusiness.model.headquarter.BusinessHeadquarter; import org.mxchange.jusercore.model.user.LoginUser; import org.mxchange.jusercore.model.user.User; import org.mxchange.jcontactsbusiness.model.employee.Employable; import org.mxchange.jcontactsbusiness.model.basicdata.BasicData; -import org.mxchange.jcontactsbusiness.model.headquarters.Headquarter; +import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter; /** * A POJO for company departments @@ -91,9 +91,9 @@ public class BusinessDepartment implements Department { /** * Where this department is located */ - @JoinColumn (name = "department_headquarters_id") - @OneToOne (targetEntity = BusinessHeadquarters.class, cascade = CascadeType.REFRESH) - private Headquarter departmentHeadquarters; + @JoinColumn (name = "department_headquarter_id") + @OneToOne (targetEntity = BusinessHeadquarter.class, cascade = CascadeType.REFRESH) + private Headquarter departmentHeadquarter; /** * Department i18n key @@ -211,13 +211,13 @@ public class BusinessDepartment implements Department { } @Override - public Headquarter getDepartmentHeadquarters () { - return this.departmentHeadquarters; + public Headquarter getDepartmentHeadquarter () { + return this.departmentHeadquarter; } @Override - public void setDepartmentHeadquarters (final Headquarter departmentHeadquarters) { - this.departmentHeadquarters = departmentHeadquarters; + public void setDepartmentHeadquarter (final Headquarter departmentHeadquarter) { + this.departmentHeadquarter = departmentHeadquarter; } @Override diff --git a/src/org/mxchange/jcontactsbusiness/model/department/Department.java b/src/org/mxchange/jcontactsbusiness/model/department/Department.java index 36ecead..6ad8466 100644 --- a/src/org/mxchange/jcontactsbusiness/model/department/Department.java +++ b/src/org/mxchange/jcontactsbusiness/model/department/Department.java @@ -22,7 +22,7 @@ import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice; import org.mxchange.jusercore.model.user.User; import org.mxchange.jcontactsbusiness.model.employee.Employable; import org.mxchange.jcontactsbusiness.model.basicdata.BasicData; -import org.mxchange.jcontactsbusiness.model.headquarters.Headquarter; +import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter; /** * A POJI for company departments @@ -46,18 +46,18 @@ public interface Department extends Serializable { void setDepartmentCompany (final BasicData departmentCompany); /** - * Getter for connection to company headquarters + * Getter for connection to company headquarter *

- * @return Connection to company headquarters + * @return Connection to company headquarter */ - Headquarter getDepartmentHeadquarters (); + Headquarter getDepartmentHeadquarter (); /** - * Setter for connection to company headquarters + * Setter for connection to company headquarter *

- * @param departmentHeadquarters Connection to company headquarters + * @param departmentHeadquarter Connection to company headquarter */ - void setDepartmentHeadquarters (final Headquarter departmentHeadquarters); + void setDepartmentHeadquarter (final Headquarter departmentHeadquarter); /** * Getter for connection to company branch office diff --git a/src/org/mxchange/jcontactsbusiness/model/employee/BusinessEmployee.java b/src/org/mxchange/jcontactsbusiness/model/employee/BusinessEmployee.java index d2407d7..fb9c820 100644 --- a/src/org/mxchange/jcontactsbusiness/model/employee/BusinessEmployee.java +++ b/src/org/mxchange/jcontactsbusiness/model/employee/BusinessEmployee.java @@ -41,8 +41,8 @@ import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice; import org.mxchange.jcontactsbusiness.model.branchoffice.BusinessBranchOffice; import org.mxchange.jcontactsbusiness.model.department.BusinessDepartment; import org.mxchange.jcontactsbusiness.model.department.Department; -import org.mxchange.jcontactsbusiness.model.headquarters.BusinessHeadquarters; -import org.mxchange.jcontactsbusiness.model.headquarters.Headquarter; +import org.mxchange.jcontactsbusiness.model.headquarter.BusinessHeadquarter; +import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter; import org.mxchange.jcontactsbusiness.model.jobposition.EmployeePosition; import org.mxchange.jcontactsbusiness.model.jobposition.JobPosition; import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber; @@ -109,8 +109,8 @@ public class BusinessEmployee implements Employable { /** * Head quarters id number (if the employee works there) */ - @JoinColumn (name = "employee_headquarters_id") - @OneToOne (targetEntity = BusinessHeadquarters.class, cascade = CascadeType.REFRESH) + @JoinColumn (name = "employee_headquarter_id") + @OneToOne (targetEntity = BusinessHeadquarter.class, cascade = CascadeType.REFRESH) private Headquarter employeeHeadquarter; /** diff --git a/src/org/mxchange/jcontactsbusiness/model/employee/Employable.java b/src/org/mxchange/jcontactsbusiness/model/employee/Employable.java index 4063171..532f1da 100644 --- a/src/org/mxchange/jcontactsbusiness/model/employee/Employable.java +++ b/src/org/mxchange/jcontactsbusiness/model/employee/Employable.java @@ -25,7 +25,7 @@ import org.mxchange.jcontactsbusiness.model.jobposition.JobPosition; import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber; import org.mxchange.jusercore.model.user.User; import org.mxchange.jcontactsbusiness.model.basicdata.BasicData; -import org.mxchange.jcontactsbusiness.model.headquarters.Headquarter; +import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter; /** * A POJI for employees diff --git a/src/org/mxchange/jcontactsbusiness/model/headquarter/BusinessHeadquarter.java b/src/org/mxchange/jcontactsbusiness/model/headquarter/BusinessHeadquarter.java new file mode 100644 index 0000000..4baeeaa --- /dev/null +++ b/src/org/mxchange/jcontactsbusiness/model/headquarter/BusinessHeadquarter.java @@ -0,0 +1,433 @@ +/* + * Copyright (C) 2016 KLC + * + * 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 . + */ +package org.mxchange.jcontactsbusiness.model.headquarter; + +import java.text.MessageFormat; +import java.util.Date; +import java.util.List; +import java.util.Objects; +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.JoinTable; +import javax.persistence.ManyToMany; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.OneToOne; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.persistence.Transient; +import org.mxchange.jcontactsbusiness.model.employee.BusinessEmployee; +import org.mxchange.jcontactsbusiness.model.employee.Employable; +import org.mxchange.jcontactsbusiness.model.opening_time.BusinessOpeningTime; +import org.mxchange.jcontactsbusiness.model.opening_time.OpeningTime; +import org.mxchange.jcountry.model.data.Country; +import org.mxchange.jcountry.model.data.CountryData; +import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber; +import org.mxchange.jphone.model.phonenumbers.fax.FaxNumber; +import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber; +import org.mxchange.jphone.model.phonenumbers.landline.LandLineNumber; +import org.mxchange.jusercore.model.user.LoginUser; +import org.mxchange.jusercore.model.user.User; + +/** + * A POJO for company headquarter data + *

+ * @author Roland Häder + */ +@Entity (name = "company_headquarter") +@Table (name = "company_headquarter") +@NamedQueries ( + { + @NamedQuery (name = "AllHeadquarters", query = "SELECT hq FROM company_headquarter AS hq ORDER BY hq.headquarterId ASC") + } +) +@SuppressWarnings ("PersistenceUnitPresent") +public class BusinessHeadquarter implements Headquarter { + + /** + * Serial number + */ + @Transient + private static final long serialVersionUID = 385_752_948_781_761L; + + /** + * Headquarter' city name + */ + @Basic (optional = false) + @Column (name = "headquarter_city", length = 100, nullable = false) + private String headquarterCity; + + /** + * Reference to contact person + */ + @JoinColumn (name = "headquarter_contact_employee_id", referencedColumnName = "employee_id") + @OneToOne (targetEntity = BusinessEmployee.class, cascade = CascadeType.REFRESH) + private Employable headquarterContactEmployee; + + /** + * Headquarter's country code + */ + @JoinColumn (name = "headquarter_country_id", nullable = false) + @OneToOne (targetEntity = CountryData.class, cascade = CascadeType.REFRESH, optional = false) + private Country headquarterCountry; + + /** + * Timestamp when this entry has been created + */ + @Basic (optional = false) + @Temporal (TemporalType.TIMESTAMP) + @Column (name = "headquarter_entry_created", nullable = false, updatable = false) + private Date headquarterCreated; + + /** + * Email address of headquarter + */ + @Column (name = "headquarter_email_address") + private String headquarterEmailAddress; + + /** + * Headquarter' fax number + */ + @JoinColumn (name = "headquarter_fax_number_id") + @OneToOne (targetEntity = FaxNumber.class, cascade = CascadeType.ALL) + private DialableFaxNumber headquarterFaxNumber; + + /** + * Headquarter' house number + */ + @Basic (optional = false) + @Column (name = "headquarter_house_number", length = 4, nullable = false) + private Short headquarterHouseNumber; + + /** + * Id number + */ + @Id + @GeneratedValue (strategy = GenerationType.IDENTITY) + @Column (name = "headquarter_id", nullable = false, updatable = false) + private Long headquarterId; + + /** + * Headquarter' land-line number + */ + @JoinColumn (name = "headquarter_landline_number_id") + @OneToOne (targetEntity = LandLineNumber.class, cascade = CascadeType.ALL) + private DialableLandLineNumber headquarterLandLineNumber; + + /** + * Opening times for this branch office + */ + @JoinTable (name = "headquarter_opening_times", joinColumns =@JoinColumn (name = "headquarter_opening_id", referencedColumnName = "headquarter_id"), inverseJoinColumns = @JoinColumn (name = "opening_headquarter_id", referencedColumnName = "opening_times_id")) + @ManyToMany (targetEntity = BusinessOpeningTime.class, cascade = CascadeType.ALL) + private List headquarterOpeningTimes; + + /** + * Headquarter' store number (multi-store building only) + */ + @Column (name = "headquarter_store", length = 3) + private Short headquarterStore; + + /** + * Headquarter' street name + */ + @Basic (optional = false) + @Column (name = "headquarter_street", length = 100, nullable = false) + private String headquarterStreet; + + /** + * Headquarter' suite number + */ + @Column (name = "headquarter_suite_number", length = 4) + private Short headquarterSuiteNumber; + + /** + * User owner instance + */ + @JoinColumn (name = "headquarter_user_id") + @OneToOne (targetEntity = LoginUser.class, cascade = CascadeType.REFRESH) + private User headquarterUserOwner; + + /** + * Headquarter' ZIP code + */ + @Basic (optional = false) + @Column (name = "headquarter_zip_code", length = 6, nullable = false) + private Integer headquarterZipCode; + + /** + * Default constructor + */ + public BusinessHeadquarter () { + } + + public BusinessHeadquarter (final String headquarterCity, final Country headquarterCountry, final String headquarterStreet, final Integer headquarterZipCode, final Short headquarterHouseNumber) { + // Call other constructor first + this(); + + // Validate parameters + if (null == headquarterCity) { + // Throw NPE + throw new NullPointerException("headquarterCity is null"); //NOI18N + } else if (headquarterCity.isEmpty()) { + // Throw IAE + throw new IllegalArgumentException("headquarterCity is empty"); //NOI18N + } else if (null == headquarterCountry) { + // Throw NPE + throw new NullPointerException("headquarterCountry is null"); //NOI18N + } else if (headquarterCountry.getCountryId() == null) { + // Throw NPE again + throw new NullPointerException("headquarterCountry.countryId is null"); //NOI18N + } else if (headquarterCountry.getCountryId() < 1) { + // Throw IAE + throw new IllegalArgumentException(MessageFormat.format("headquarterCountry.countryId={0} is not valid.", headquarterCountry.getCountryId())); //NOI18N + } else if (null == headquarterHouseNumber) { + // Throw NPE + throw new NullPointerException("headquarterHouseNumber is null"); //NOI18N + } else if (headquarterHouseNumber < 1) { + // Throw IAE + throw new IllegalArgumentException(MessageFormat.format("headquarterHouseNumber={0} is invalid.", headquarterHouseNumber)); //NOI18N + } else if (null == headquarterStreet) { + // Throw NPE + throw new NullPointerException("headquarterStreet is null"); //NOI18N + } else if (headquarterStreet.isEmpty()) { + // Throw IAE + throw new IllegalArgumentException("headquarterStreet is empty"); //NOI18N + } else if (null == headquarterZipCode) { + // Throw NPE + throw new NullPointerException("headquarterZipCode is null"); //NOI18N + } else if (headquarterZipCode < 1) { + // Throw IAE + throw new IllegalArgumentException(MessageFormat.format("headquarterZipCode={0} is invalid.", headquarterZipCode)); //NOI18N + } + + // Set all fields + this.headquarterCity = headquarterCity; + this.headquarterCountry = headquarterCountry; + this.headquarterHouseNumber = headquarterHouseNumber; + this.headquarterStreet = headquarterStreet; + this.headquarterZipCode = headquarterZipCode; + } + + @Override + public boolean equals (final Object object) { + if (null == object) { + return false; + } else if (this.getClass() != object.getClass()) { + return false; + } + + final Headquarter headquarter = (Headquarter) object; + + if (!Objects.equals(this.getHeadquarterId(), headquarter.getHeadquarterId())) { + return false; + } else if (!Objects.equals(this.getHeadquarterCity(), headquarter.getHeadquarterCity())) { + return false; + } else if (!Objects.equals(this.getHeadquarterCountry(), headquarter.getHeadquarterCountry())) { + return false; + } else if (!Objects.equals(this.getHeadquarterHouseNumber(), headquarter.getHeadquarterHouseNumber())) { + return false; + } else if (!Objects.equals(this.getHeadquarterStore(), headquarter.getHeadquarterStore())) { + return false; + } else if (!Objects.equals(this.getHeadquarterStreet(), headquarter.getHeadquarterStreet())) { + return false; + } else if (!Objects.equals(this.getHeadquarterSuiteNumber(), headquarter.getHeadquarterSuiteNumber())) { + return false; + } else if (!Objects.equals(this.getHeadquarterZipCode(), headquarter.getHeadquarterZipCode())) { + return false; + } + + return true; + } + + @Override + public String getHeadquarterCity () { + return this.headquarterCity; + } + + @Override + public void setHeadquarterCity (final String headquarterCity) { + this.headquarterCity = headquarterCity; + } + + @Override + public Employable getHeadquarterContactEmployee () { + return this.headquarterContactEmployee; + } + + @Override + public void setHeadquarterContactEmployee (final Employable headquarterContactEmployee) { + this.headquarterContactEmployee = headquarterContactEmployee; + } + + @Override + public Country getHeadquarterCountry () { + return this.headquarterCountry; + } + + @Override + public void setHeadquarterCountry (final Country headquarterCountry) { + this.headquarterCountry = headquarterCountry; + } + + @Override + @SuppressWarnings ("ReturnOfDateField") + public Date getHeadquarterCreated () { + return this.headquarterCreated; + } + + @Override + @SuppressWarnings ("AssignmentToDateFieldFromParameter") + public void setHeadquarterCreated (final Date headquarterCreated) { + this.headquarterCreated = headquarterCreated; + } + + @Override + public String getHeadquarterEmailAddress () { + return this.headquarterEmailAddress; + } + + @Override + public void setHeadquarterEmailAddress (final String headquarterEmailAddress) { + this.headquarterEmailAddress = headquarterEmailAddress; + } + + @Override + public DialableFaxNumber getHeadquarterFaxNumber () { + return this.headquarterFaxNumber; + } + + @Override + public void setHeadquarterFaxNumber (final DialableFaxNumber headquarterFaxNumber) { + this.headquarterFaxNumber = headquarterFaxNumber; + } + + @Override + public Short getHeadquarterHouseNumber () { + return this.headquarterHouseNumber; + } + + @Override + public void setHeadquarterHouseNumber (final Short headquarterHouseNumber) { + this.headquarterHouseNumber = headquarterHouseNumber; + } + + @Override + public Long getHeadquarterId () { + return this.headquarterId; + } + + @Override + public void setHeadquarterId (final Long headquarterId) { + this.headquarterId = headquarterId; + } + + @Override + public DialableLandLineNumber getHeadquarterLandLineNumber () { + return this.headquarterLandLineNumber; + } + + @Override + public void setHeadquarterLandLineNumber (final DialableLandLineNumber headquarterLandLineNumber) { + this.headquarterLandLineNumber = headquarterLandLineNumber; + } + + @Override + @SuppressWarnings ("ReturnOfCollectionOrArrayField") + public List getHeadquarterOpeningTimes () { + return this.headquarterOpeningTimes; + } + + @Override + @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter") + public void setHeadquarterOpeningTimes (final List headquarterOpeningTimes) { + this.headquarterOpeningTimes = headquarterOpeningTimes; + } + + @Override + public Short getHeadquarterStore () { + return this.headquarterStore; + } + + @Override + public void setHeadquarterStore (final Short headquarterStore) { + this.headquarterStore = headquarterStore; + } + + @Override + public String getHeadquarterStreet () { + return this.headquarterStreet; + } + + @Override + public void setHeadquarterStreet (final String headquarterStreet) { + this.headquarterStreet = headquarterStreet; + } + + @Override + public Short getHeadquarterSuiteNumber () { + return this.headquarterSuiteNumber; + } + + @Override + public void setHeadquarterSuiteNumber (final Short headquarterSuiteNumber) { + this.headquarterSuiteNumber = headquarterSuiteNumber; + } + + @Override + public User getHeadquarterUserOwner () { + return this.headquarterUserOwner; + } + + @Override + public void setHeadquarterUserOwner (final User headquarterUserOwner) { + this.headquarterUserOwner = headquarterUserOwner; + } + + @Override + public Integer getHeadquarterZipCode () { + return this.headquarterZipCode; + } + + @Override + public void setHeadquarterZipCode (final Integer headquarterZipCode) { + this.headquarterZipCode = headquarterZipCode; + } + + @Override + public int hashCode () { + int hash = 7; + + hash = 47 * hash + Objects.hashCode(this.getHeadquarterId()); + hash = 47 * hash + Objects.hashCode(this.getHeadquarterCity()); + hash = 47 * hash + Objects.hashCode(this.getHeadquarterCountry()); + hash = 47 * hash + Objects.hashCode(this.getHeadquarterHouseNumber()); + hash = 47 * hash + Objects.hashCode(this.getHeadquarterStore()); + hash = 47 * hash + Objects.hashCode(this.getHeadquarterStreet()); + hash = 47 * hash + Objects.hashCode(this.getHeadquarterSuiteNumber()); + hash = 47 * hash + Objects.hashCode(this.getHeadquarterZipCode()); + + return hash; + } + +} diff --git a/src/org/mxchange/jcontactsbusiness/model/headquarter/Headquarter.java b/src/org/mxchange/jcontactsbusiness/model/headquarter/Headquarter.java new file mode 100644 index 0000000..cc76d59 --- /dev/null +++ b/src/org/mxchange/jcontactsbusiness/model/headquarter/Headquarter.java @@ -0,0 +1,252 @@ +/* + * 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 . + */ +package org.mxchange.jcontactsbusiness.model.headquarter; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; +import org.mxchange.jcontactsbusiness.model.employee.Employable; +import org.mxchange.jcontactsbusiness.model.opening_time.OpeningTime; +import org.mxchange.jcountry.model.data.Country; +import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber; +import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber; +import org.mxchange.jusercore.model.user.User; + +/** + * A POJI for headquarter data + *

+ * @author Roland Häder + */ +public interface Headquarter extends Serializable { + + /** + * Getter for headquarter' city name + *

+ * @return Headquarter' city name + */ + String getHeadquarterCity (); + + /** + * Setter for headquarter' city name + *

+ * @param headquarterCity Headquarter' city name + */ + void setHeadquarterCity (final String headquarterCity); + + /** + * Getter for headquarter' country code + *

+ * @return Headquarter' country code + */ + Country getHeadquarterCountry (); + + /** + * Setter for headquarter' country code + *

+ * @param headquarterCountryCode Headquarter' country code + */ + void setHeadquarterCountry (final Country headquarterCountryCode); + + /** + * Getter for headquarter' house number + *

+ * @return Headquarter' house number + */ + Short getHeadquarterHouseNumber (); + + /** + * Setter for headquarter' house number + *

+ * @param headquarterHouseNumber Headquarter' house number + */ + void setHeadquarterHouseNumber (final Short headquarterHouseNumber); + + /** + * Getter for headquarter' id number + *

+ * @return Headquarter' id number + */ + Long getHeadquarterId (); + + /** + * Setter for headquarter' id number + *

+ * @param headquarterId Headquarter' id number + */ + void setHeadquarterId (final Long headquarterId); + + /** + * Getter for headquarter' store number + *

+ * @return Headquarter' store number + */ + Short getHeadquarterStore (); + + /** + * Setter for headquarter' store number + *

+ * @param headquarterStore Headquarter' store number + */ + void setHeadquarterStore (final Short headquarterStore); + + /** + * Getter for headquarter' street name + *

+ * @return Headquarter' street name + */ + String getHeadquarterStreet (); + + /** + * Setter for headquarter' street name + *

+ * @param headquarterStreet Headquarter' street name + */ + void setHeadquarterStreet (final String headquarterStreet); + + /** + * Getter for headquarter' suite number + *

+ * @return Headquarter' suite number + */ + Short getHeadquarterSuiteNumber (); + + /** + * Setter for headquarter' suite number + *

+ * @param headquarterSuiteNumber Headquarter' suite number + */ + void setHeadquarterSuiteNumber (final Short headquarterSuiteNumber); + + /** + * Getter for headquarter' ZIP code + *

+ * @return Headquarter' ZIP code + */ + Integer getHeadquarterZipCode (); + + /** + * Setter for headquarter' ZIP code + *

+ * @param headquarterZipCode Headquarter' ZIP code + */ + void setHeadquarterZipCode (final Integer headquarterZipCode); + + /** + * Getter for headquarter' land-line number + *

+ * @return Headquarter' land-line number + */ + DialableLandLineNumber getHeadquarterLandLineNumber (); + + /** + * Setter for headquarter' land-line number + *

+ * @param headquarterLandLineNumber Headquarter' land-line number + */ + void setHeadquarterLandLineNumber (final DialableLandLineNumber headquarterLandLineNumber); + + /** + * Getter for headquarter' fax number + *

+ * @return Headquarter' fax number + */ + DialableFaxNumber getHeadquarterFaxNumber (); + + /** + * Setter for headquarter' fax number + *

+ * @param headquarterFaxNumber Headquarter' fax number + */ + void setHeadquarterFaxNumber (final DialableFaxNumber headquarterFaxNumber); + + /** + * Getter for user owner instance + *

+ * @return User owner instance + */ + User getHeadquarterUserOwner (); + + /** + * Setter for user owner instance + *

+ * @param headquarterUserOwner User owner instance + */ + void setHeadquarterUserOwner (final User headquarterUserOwner); + + /** + * Getter for branch office owning employee + *

+ * @return Owning employee + */ + Employable getHeadquarterContactEmployee (); + + /** + * Setter for branch office contact person + *

+ * @param branchContactEmployee Contact person + */ + void setHeadquarterContactEmployee (final Employable branchContactEmployee); + + /** + * Getter for opening times for this branch office + *

+ * @return Opening times + */ + List getHeadquarterOpeningTimes (); + + /** + * Setter for opening times for this branch office + *

+ * @param branchOpeningTimes Opening times + */ + void setHeadquarterOpeningTimes (final List branchOpeningTimes); + + /** + * Getter for headquarter' email address + *

+ * @return Headquarter' email address + */ + String getHeadquarterEmailAddress (); + + /** + * Setter for headquarter' email address + *

+ * @param headquarterEmailAddress Headquarter' email address + */ + void setHeadquarterEmailAddress (final String headquarterEmailAddress); + + /** + * Getter for timestamp when this entry has been created + *

+ * @return Timestamp when this entry has been created + */ + Date getHeadquarterCreated (); + + /** + * Setter for timestamp when this entry has been created + *

+ * @param headquarterCreated Timestamp when this entry has been created + */ + void setHeadquarterCreated (final Date headquarterCreated); + + @Override + boolean equals (final Object object); + + @Override + int hashCode (); + +} diff --git a/src/org/mxchange/jcontactsbusiness/model/headquarter/Headquarters.java b/src/org/mxchange/jcontactsbusiness/model/headquarter/Headquarters.java new file mode 100644 index 0000000..9598374 --- /dev/null +++ b/src/org/mxchange/jcontactsbusiness/model/headquarter/Headquarters.java @@ -0,0 +1,93 @@ +/* + * 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 . + */ +package org.mxchange.jcontactsbusiness.model.headquarter; + +import java.io.Serializable; +import java.util.Objects; + +/** + * An utilities class for headquarter + * + * @author Roland Häder + */ +public class Headquarters implements Serializable { + + /** + * Serial number + */ + private static final long serialVersionUID = 69_537_867_224_651L; + + /** + * Checks if both headquarter have same address. This method will throw + * an {@code NullPointerException} if one of the instances is null. + *

+ * @param headquarter1 Headquarter 1 + * @param headquarter2 Headquarter 2 + *

+ * @return Whether both branch office addresses are the same + *

+ * @throws NullPointerException If one of the instances is null + */ + public static boolean isSameAddress (final Headquarter headquarter1, final Headquarter headquarter2) { + // Check that both parameters are not null + if (null == headquarter1) { + // Throw NPE + throw new NullPointerException("headquarter1 is null"); //NOI18N + } else if (null == headquarter2) { + // Throw NPE + throw new NullPointerException("headquarter2 is null"); //NOI18N + } + + // Default is the same + boolean isSameAddress = true; + + // Compare both addresses + if (!Objects.equals(headquarter1.getHeadquarterCountry(), headquarter2.getHeadquarterCountry())) { + // Not the same + isSameAddress = false; + } else if (!Objects.equals(headquarter1.getHeadquarterCity(), headquarter2.getHeadquarterCity())) { + // Not the same + isSameAddress = false; + } else if (!Objects.equals(headquarter1.getHeadquarterZipCode(), headquarter2.getHeadquarterZipCode())) { + // Not the same + isSameAddress = false; + } else if (!Objects.equals(headquarter1.getHeadquarterStreet(), headquarter2.getHeadquarterStreet())) { + // Not the same + isSameAddress = false; + } else if (!Objects.equals(headquarter1.getHeadquarterHouseNumber(), headquarter2.getHeadquarterHouseNumber())) { + // Not the same + isSameAddress = false; + } else if (!Objects.equals(headquarter1.getHeadquarterStore(), headquarter2.getHeadquarterStore())) { + // Not the same + isSameAddress = false; + } else if (!Objects.equals(headquarter1.getHeadquarterSuiteNumber(), headquarter2.getHeadquarterSuiteNumber())) { + // Not the same + isSameAddress = false; + } + + // Return flag + return isSameAddress; + } + + /** + * Private default constructor + */ + private Headquarters () { + // Utilities don't have instances + } + +} diff --git a/src/org/mxchange/jcontactsbusiness/model/headquarters/BusinessHeadquarters.java b/src/org/mxchange/jcontactsbusiness/model/headquarters/BusinessHeadquarters.java deleted file mode 100644 index fc8dc39..0000000 --- a/src/org/mxchange/jcontactsbusiness/model/headquarters/BusinessHeadquarters.java +++ /dev/null @@ -1,433 +0,0 @@ -/* - * Copyright (C) 2016 KLC - * - * 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 . - */ -package org.mxchange.jcontactsbusiness.model.headquarters; - -import java.text.MessageFormat; -import java.util.Date; -import java.util.List; -import java.util.Objects; -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.JoinTable; -import javax.persistence.ManyToMany; -import javax.persistence.NamedQueries; -import javax.persistence.NamedQuery; -import javax.persistence.OneToOne; -import javax.persistence.Table; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; -import javax.persistence.Transient; -import org.mxchange.jcontactsbusiness.model.employee.BusinessEmployee; -import org.mxchange.jcontactsbusiness.model.employee.Employable; -import org.mxchange.jcontactsbusiness.model.opening_time.BusinessOpeningTime; -import org.mxchange.jcontactsbusiness.model.opening_time.OpeningTime; -import org.mxchange.jcountry.model.data.Country; -import org.mxchange.jcountry.model.data.CountryData; -import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber; -import org.mxchange.jphone.model.phonenumbers.fax.FaxNumber; -import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber; -import org.mxchange.jphone.model.phonenumbers.landline.LandLineNumber; -import org.mxchange.jusercore.model.user.LoginUser; -import org.mxchange.jusercore.model.user.User; - -/** - * A POJO for company headquarters data - *

- * @author Roland Häder - */ -@Entity (name = "company_headquarters") -@Table (name = "company_headquarters") -@NamedQueries ( - { - @NamedQuery (name = "AllHeadquarters", query = "SELECT hq FROM company_headquarters AS hq ORDER BY hq.headquartersId ASC") - } -) -@SuppressWarnings ("PersistenceUnitPresent") -public class BusinessHeadquarters implements Headquarter { - - /** - * Serial number - */ - @Transient - private static final long serialVersionUID = 385_752_948_781_761L; - - /** - * Headquarter' city name - */ - @Basic (optional = false) - @Column (name = "headquarters_city", length = 100, nullable = false) - private String headquartersCity; - - /** - * Reference to contact person - */ - @JoinColumn (name = "headquarters_contact_employee_id", referencedColumnName = "employee_id") - @OneToOne (targetEntity = BusinessEmployee.class, cascade = CascadeType.REFRESH) - private Employable headquartersContactEmployee; - - /** - * Headquarter's country code - */ - @JoinColumn (name = "headquarters_country_id", nullable = false) - @OneToOne (targetEntity = CountryData.class, cascade = CascadeType.REFRESH, optional = false) - private Country headquartersCountry; - - /** - * Timestamp when this entry has been created - */ - @Basic (optional = false) - @Temporal (TemporalType.TIMESTAMP) - @Column (name = "headquarters_entry_created", nullable = false, updatable = false) - private Date headquartersCreated; - - /** - * Email address of headquarters - */ - @Column (name = "headquarters_email_address") - private String headquartersEmailAddress; - - /** - * Headquarter' fax number - */ - @JoinColumn (name = "headquarters_fax_number_id") - @OneToOne (targetEntity = FaxNumber.class, cascade = CascadeType.ALL) - private DialableFaxNumber headquartersFaxNumber; - - /** - * Headquarter' house number - */ - @Basic (optional = false) - @Column (name = "headquarters_house_number", length = 4, nullable = false) - private Short headquartersHouseNumber; - - /** - * Id number - */ - @Id - @GeneratedValue (strategy = GenerationType.IDENTITY) - @Column (name = "headquarters_id", nullable = false, updatable = false) - private Long headquartersId; - - /** - * Headquarter' land-line number - */ - @JoinColumn (name = "headquarters_landline_number_id") - @OneToOne (targetEntity = LandLineNumber.class, cascade = CascadeType.ALL) - private DialableLandLineNumber headquartersLandLineNumber; - - /** - * Opening times for this branch office - */ - @JoinTable (name = "headquarters_opening_times", joinColumns =@JoinColumn (name = "headquarters_opening_id", referencedColumnName = "headquarters_id"), inverseJoinColumns = @JoinColumn (name = "opening_headquarters_id", referencedColumnName = "opening_times_id")) - @ManyToMany (targetEntity = BusinessOpeningTime.class, cascade = CascadeType.ALL) - private List headquartersOpeningTimes; - - /** - * Headquarter' store number (multi-store building only) - */ - @Column (name = "headquarters_store", length = 3) - private Short headquartersStore; - - /** - * Headquarter' street name - */ - @Basic (optional = false) - @Column (name = "headquarters_street", length = 100, nullable = false) - private String headquartersStreet; - - /** - * Headquarter' suite number - */ - @Column (name = "headquarters_suite_number", length = 4) - private Short headquartersSuiteNumber; - - /** - * User owner instance - */ - @JoinColumn (name = "headquarters_user_id") - @OneToOne (targetEntity = LoginUser.class, cascade = CascadeType.REFRESH) - private User headquartersUserOwner; - - /** - * Headquarter' ZIP code - */ - @Basic (optional = false) - @Column (name = "headquarters_zip_code", length = 6, nullable = false) - private Integer headquartersZipCode; - - /** - * Default constructor - */ - public BusinessHeadquarters () { - } - - public BusinessHeadquarters (final String headquartersCity, final Country headquartersCountry, final String headquartersStreet, final Integer headquartersZipCode, final Short headquartersHouseNumber) { - // Call other constructor first - this(); - - // Validate parameters - if (null == headquartersCity) { - // Throw NPE - throw new NullPointerException("headquartersCity is null"); //NOI18N - } else if (headquartersCity.isEmpty()) { - // Throw IAE - throw new IllegalArgumentException("headquartersCity is empty"); //NOI18N - } else if (null == headquartersCountry) { - // Throw NPE - throw new NullPointerException("headquartersCountry is null"); //NOI18N - } else if (headquartersCountry.getCountryId() == null) { - // Throw NPE again - throw new NullPointerException("headquartersCountry.countryId is null"); //NOI18N - } else if (headquartersCountry.getCountryId() < 1) { - // Throw IAE - throw new IllegalArgumentException(MessageFormat.format("headquartersCountry.countryId={0} is not valid.", headquartersCountry.getCountryId())); //NOI18N - } else if (null == headquartersHouseNumber) { - // Throw NPE - throw new NullPointerException("headquartersHouseNumber is null"); //NOI18N - } else if (headquartersHouseNumber < 1) { - // Throw IAE - throw new IllegalArgumentException(MessageFormat.format("headquartersHouseNumber={0} is invalid.", headquartersHouseNumber)); //NOI18N - } else if (null == headquartersStreet) { - // Throw NPE - throw new NullPointerException("headquartersStreet is null"); //NOI18N - } else if (headquartersStreet.isEmpty()) { - // Throw IAE - throw new IllegalArgumentException("headquartersStreet is empty"); //NOI18N - } else if (null == headquartersZipCode) { - // Throw NPE - throw new NullPointerException("headquartersZipCode is null"); //NOI18N - } else if (headquartersZipCode < 1) { - // Throw IAE - throw new IllegalArgumentException(MessageFormat.format("headquartersZipCode={0} is invalid.", headquartersZipCode)); //NOI18N - } - - // Set all fields - this.headquartersCity = headquartersCity; - this.headquartersCountry = headquartersCountry; - this.headquartersHouseNumber = headquartersHouseNumber; - this.headquartersStreet = headquartersStreet; - this.headquartersZipCode = headquartersZipCode; - } - - @Override - public boolean equals (final Object object) { - if (null == object) { - return false; - } else if (this.getClass() != object.getClass()) { - return false; - } - - final Headquarter headquarter = (Headquarter) object; - - if (!Objects.equals(this.getHeadquartersId(), headquarter.getHeadquartersId())) { - return false; - } else if (!Objects.equals(this.getHeadquartersCity(), headquarter.getHeadquartersCity())) { - return false; - } else if (!Objects.equals(this.getHeadquartersCountry(), headquarter.getHeadquartersCountry())) { - return false; - } else if (!Objects.equals(this.getHeadquartersHouseNumber(), headquarter.getHeadquartersHouseNumber())) { - return false; - } else if (!Objects.equals(this.getHeadquartersStore(), headquarter.getHeadquartersStore())) { - return false; - } else if (!Objects.equals(this.getHeadquartersStreet(), headquarter.getHeadquartersStreet())) { - return false; - } else if (!Objects.equals(this.getHeadquartersSuiteNumber(), headquarter.getHeadquartersSuiteNumber())) { - return false; - } else if (!Objects.equals(this.getHeadquartersZipCode(), headquarter.getHeadquartersZipCode())) { - return false; - } - - return true; - } - - @Override - public String getHeadquartersCity () { - return this.headquartersCity; - } - - @Override - public void setHeadquartersCity (final String headquartersCity) { - this.headquartersCity = headquartersCity; - } - - @Override - public Employable getHeadquartersContactEmployee () { - return this.headquartersContactEmployee; - } - - @Override - public void setHeadquartersContactEmployee (final Employable headquartersContactEmployee) { - this.headquartersContactEmployee = headquartersContactEmployee; - } - - @Override - public Country getHeadquartersCountry () { - return this.headquartersCountry; - } - - @Override - public void setHeadquartersCountry (final Country headquartersCountry) { - this.headquartersCountry = headquartersCountry; - } - - @Override - @SuppressWarnings ("ReturnOfDateField") - public Date getHeadquartersCreated () { - return this.headquartersCreated; - } - - @Override - @SuppressWarnings ("AssignmentToDateFieldFromParameter") - public void setHeadquartersCreated (final Date headquartersCreated) { - this.headquartersCreated = headquartersCreated; - } - - @Override - public String getHeadquartersEmailAddress () { - return this.headquartersEmailAddress; - } - - @Override - public void setHeadquartersEmailAddress (final String headquartersEmailAddress) { - this.headquartersEmailAddress = headquartersEmailAddress; - } - - @Override - public DialableFaxNumber getHeadquartersFaxNumber () { - return this.headquartersFaxNumber; - } - - @Override - public void setHeadquartersFaxNumber (final DialableFaxNumber headquartersFaxNumber) { - this.headquartersFaxNumber = headquartersFaxNumber; - } - - @Override - public Short getHeadquartersHouseNumber () { - return this.headquartersHouseNumber; - } - - @Override - public void setHeadquartersHouseNumber (final Short headquartersHouseNumber) { - this.headquartersHouseNumber = headquartersHouseNumber; - } - - @Override - public Long getHeadquartersId () { - return this.headquartersId; - } - - @Override - public void setHeadquartersId (final Long headquartersId) { - this.headquartersId = headquartersId; - } - - @Override - public DialableLandLineNumber getHeadquartersLandLineNumber () { - return this.headquartersLandLineNumber; - } - - @Override - public void setHeadquartersLandLineNumber (final DialableLandLineNumber headquartersLandLineNumber) { - this.headquartersLandLineNumber = headquartersLandLineNumber; - } - - @Override - @SuppressWarnings ("ReturnOfCollectionOrArrayField") - public List getHeadquartersOpeningTimes () { - return this.headquartersOpeningTimes; - } - - @Override - @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter") - public void setHeadquartersOpeningTimes (final List headquartersOpeningTimes) { - this.headquartersOpeningTimes = headquartersOpeningTimes; - } - - @Override - public Short getHeadquartersStore () { - return this.headquartersStore; - } - - @Override - public void setHeadquartersStore (final Short headquartersStore) { - this.headquartersStore = headquartersStore; - } - - @Override - public String getHeadquartersStreet () { - return this.headquartersStreet; - } - - @Override - public void setHeadquartersStreet (final String headquartersStreet) { - this.headquartersStreet = headquartersStreet; - } - - @Override - public Short getHeadquartersSuiteNumber () { - return this.headquartersSuiteNumber; - } - - @Override - public void setHeadquartersSuiteNumber (final Short headquartersSuiteNumber) { - this.headquartersSuiteNumber = headquartersSuiteNumber; - } - - @Override - public User getHeadquartersUserOwner () { - return this.headquartersUserOwner; - } - - @Override - public void setHeadquartersUserOwner (final User headquartersUserOwner) { - this.headquartersUserOwner = headquartersUserOwner; - } - - @Override - public Integer getHeadquartersZipCode () { - return this.headquartersZipCode; - } - - @Override - public void setHeadquartersZipCode (final Integer headquartersZipCode) { - this.headquartersZipCode = headquartersZipCode; - } - - @Override - public int hashCode () { - int hash = 7; - - hash = 47 * hash + Objects.hashCode(this.getHeadquartersId()); - hash = 47 * hash + Objects.hashCode(this.getHeadquartersCity()); - hash = 47 * hash + Objects.hashCode(this.getHeadquartersCountry()); - hash = 47 * hash + Objects.hashCode(this.getHeadquartersHouseNumber()); - hash = 47 * hash + Objects.hashCode(this.getHeadquartersStore()); - hash = 47 * hash + Objects.hashCode(this.getHeadquartersStreet()); - hash = 47 * hash + Objects.hashCode(this.getHeadquartersSuiteNumber()); - hash = 47 * hash + Objects.hashCode(this.getHeadquartersZipCode()); - - return hash; - } - -} diff --git a/src/org/mxchange/jcontactsbusiness/model/headquarters/Headquarter.java b/src/org/mxchange/jcontactsbusiness/model/headquarters/Headquarter.java deleted file mode 100644 index 65613c7..0000000 --- a/src/org/mxchange/jcontactsbusiness/model/headquarters/Headquarter.java +++ /dev/null @@ -1,252 +0,0 @@ -/* - * 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 . - */ -package org.mxchange.jcontactsbusiness.model.headquarters; - -import java.io.Serializable; -import java.util.Date; -import java.util.List; -import org.mxchange.jcontactsbusiness.model.employee.Employable; -import org.mxchange.jcontactsbusiness.model.opening_time.OpeningTime; -import org.mxchange.jcountry.model.data.Country; -import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber; -import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber; -import org.mxchange.jusercore.model.user.User; - -/** - * A POJI for headquarters data - *

- * @author Roland Häder - */ -public interface Headquarter extends Serializable { - - /** - * Getter for headquarters' city name - *

- * @return Headquarter' city name - */ - String getHeadquartersCity (); - - /** - * Setter for headquarters' city name - *

- * @param headquartersCity Headquarter' city name - */ - void setHeadquartersCity (final String headquartersCity); - - /** - * Getter for headquarters' country code - *

- * @return Headquarter' country code - */ - Country getHeadquartersCountry (); - - /** - * Setter for headquarters' country code - *

- * @param headquartersCountryCode Headquarter' country code - */ - void setHeadquartersCountry (final Country headquartersCountryCode); - - /** - * Getter for headquarters' house number - *

- * @return Headquarter' house number - */ - Short getHeadquartersHouseNumber (); - - /** - * Setter for headquarters' house number - *

- * @param headquartersHouseNumber Headquarter' house number - */ - void setHeadquartersHouseNumber (final Short headquartersHouseNumber); - - /** - * Getter for headquarters' id number - *

- * @return Headquarter' id number - */ - Long getHeadquartersId (); - - /** - * Setter for headquarters' id number - *

- * @param headquartersId Headquarter' id number - */ - void setHeadquartersId (final Long headquartersId); - - /** - * Getter for headquarters' store number - *

- * @return Headquarter' store number - */ - Short getHeadquartersStore (); - - /** - * Setter for headquarters' store number - *

- * @param headquartersStore Headquarter' store number - */ - void setHeadquartersStore (final Short headquartersStore); - - /** - * Getter for headquarters' street name - *

- * @return Headquarter' street name - */ - String getHeadquartersStreet (); - - /** - * Setter for headquarters' street name - *

- * @param headquartersStreet Headquarter' street name - */ - void setHeadquartersStreet (final String headquartersStreet); - - /** - * Getter for headquarters' suite number - *

- * @return Headquarter' suite number - */ - Short getHeadquartersSuiteNumber (); - - /** - * Setter for headquarters' suite number - *

- * @param headquartersSuiteNumber Headquarter' suite number - */ - void setHeadquartersSuiteNumber (final Short headquartersSuiteNumber); - - /** - * Getter for headquarters' ZIP code - *

- * @return Headquarter' ZIP code - */ - Integer getHeadquartersZipCode (); - - /** - * Setter for headquarters' ZIP code - *

- * @param headquartersZipCode Headquarter' ZIP code - */ - void setHeadquartersZipCode (final Integer headquartersZipCode); - - /** - * Getter for headquarters' land-line number - *

- * @return Headquarter' land-line number - */ - DialableLandLineNumber getHeadquartersLandLineNumber (); - - /** - * Setter for headquarters' land-line number - *

- * @param headquartersLandLineNumber Headquarter' land-line number - */ - void setHeadquartersLandLineNumber (final DialableLandLineNumber headquartersLandLineNumber); - - /** - * Getter for headquarters' fax number - *

- * @return Headquarter' fax number - */ - DialableFaxNumber getHeadquartersFaxNumber (); - - /** - * Setter for headquarters' fax number - *

- * @param headquartersFaxNumber Headquarter' fax number - */ - void setHeadquartersFaxNumber (final DialableFaxNumber headquartersFaxNumber); - - /** - * Getter for user owner instance - *

- * @return User owner instance - */ - User getHeadquartersUserOwner (); - - /** - * Setter for user owner instance - *

- * @param headquartersUserOwner User owner instance - */ - void setHeadquartersUserOwner (final User headquartersUserOwner); - - /** - * Getter for branch office owning employee - *

- * @return Owning employee - */ - Employable getHeadquartersContactEmployee (); - - /** - * Setter for branch office contact person - *

- * @param branchContactEmployee Contact person - */ - void setHeadquartersContactEmployee (final Employable branchContactEmployee); - - /** - * Getter for opening times for this branch office - *

- * @return Opening times - */ - List getHeadquartersOpeningTimes (); - - /** - * Setter for opening times for this branch office - *

- * @param branchOpeningTimes Opening times - */ - void setHeadquartersOpeningTimes (final List branchOpeningTimes); - - /** - * Getter for headquarters' email address - *

- * @return Headquarters' email address - */ - String getHeadquartersEmailAddress (); - - /** - * Setter for headquarters' email address - *

- * @param headquartersEmailAddress Headquarters' email address - */ - void setHeadquartersEmailAddress (final String headquartersEmailAddress); - - /** - * Getter for timestamp when this entry has been created - *

- * @return Timestamp when this entry has been created - */ - Date getHeadquartersCreated (); - - /** - * Setter for timestamp when this entry has been created - *

- * @param headquartersCreated Timestamp when this entry has been created - */ - void setHeadquartersCreated (final Date headquartersCreated); - - @Override - boolean equals (final Object object); - - @Override - int hashCode (); - -} diff --git a/src/org/mxchange/jcontactsbusiness/model/headquarters/Headquarters.java b/src/org/mxchange/jcontactsbusiness/model/headquarters/Headquarters.java deleted file mode 100644 index 77bad86..0000000 --- a/src/org/mxchange/jcontactsbusiness/model/headquarters/Headquarters.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * 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 . - */ -package org.mxchange.jcontactsbusiness.model.headquarters; - -import java.io.Serializable; -import java.util.Objects; - -/** - * An utilities class for headquarters - * - * @author Roland Häder - */ -public class Headquarters implements Serializable { - - /** - * Serial number - */ - private static final long serialVersionUID = 69_537_867_224_651L; - - /** - * Checks if both headquarters have same address. This method will throw - * an {@code NullPointerException} if one of the instances is null. - *

- * @param headquarters1 Headquarters 1 - * @param headquarters2 Headquarters 2 - *

- * @return Whether both branch office addresses are the same - *

- * @throws NullPointerException If one of the instances is null - */ - public static boolean isSameAddress (final Headquarter headquarters1, final Headquarter headquarters2) { - // Check that both parameters are not null - if (null == headquarters1) { - // Throw NPE - throw new NullPointerException("headquarters1 is null"); //NOI18N - } else if (null == headquarters2) { - // Throw NPE - throw new NullPointerException("headquarters2 is null"); //NOI18N - } - - // Default is the same - boolean isSameAddress = true; - - // Compare both addresses - if (!Objects.equals(headquarters1.getHeadquartersCountry(), headquarters2.getHeadquartersCountry())) { - // Not the same - isSameAddress = false; - } else if (!Objects.equals(headquarters1.getHeadquartersCity(), headquarters2.getHeadquartersCity())) { - // Not the same - isSameAddress = false; - } else if (!Objects.equals(headquarters1.getHeadquartersZipCode(), headquarters2.getHeadquartersZipCode())) { - // Not the same - isSameAddress = false; - } else if (!Objects.equals(headquarters1.getHeadquartersStreet(), headquarters2.getHeadquartersStreet())) { - // Not the same - isSameAddress = false; - } else if (!Objects.equals(headquarters1.getHeadquartersHouseNumber(), headquarters2.getHeadquartersHouseNumber())) { - // Not the same - isSameAddress = false; - } else if (!Objects.equals(headquarters1.getHeadquartersStore(), headquarters2.getHeadquartersStore())) { - // Not the same - isSameAddress = false; - } else if (!Objects.equals(headquarters1.getHeadquartersSuiteNumber(), headquarters2.getHeadquartersSuiteNumber())) { - // Not the same - isSameAddress = false; - } - - // Return flag - return isSameAddress; - } - - /** - * Private default constructor - */ - private Headquarters () { - // Utilities don't have instances - } - -}