/*
- * Copyright (C) 2017 Free Software Foundation
+ * Copyright (C) 2017, 2018 Free Software Foundation
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
/*
- * Copyright (C) 2017 Free Software Foundation
+ * Copyright (C) 2017, 2018 Free Software Foundation
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
/*
- * Copyright (C) 2017 Free Software Foundation
+ * Copyright (C) 2017, 2018 Free Software Foundation
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
/*
- * Copyright (C) 2017 Free Software Foundation
+ * Copyright (C) 2017, 2018 Free Software Foundation
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
/*
- * Copyright (C) 2017 Free Software Foundation
+ * Copyright (C) 2017, 2018 Free Software Foundation
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
/*
- * Copyright (C) 2017 Free Software Foundation
+ * Copyright (C) 2017, 2018 Free Software Foundation
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
/*
- * Copyright (C) 2017 Free Software Foundation
+ * Copyright (C) 2017, 2018 Free Software Foundation
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
/*
- * Copyright (C) 2017 Free Software Foundation
+ * Copyright (C) 2017, 2018 Free Software Foundation
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
/*
- * Copyright (C) 2017 Free Software Foundation
+ * Copyright (C) 2017, 2018 Free Software Foundation
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
/*
- * Copyright (C) 2017 Free Software Foundation
+ * Copyright (C) 2017, 2018 Free Software Foundation
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
/*
- * Copyright (C) 2017 Free Software Foundation
+ * Copyright (C) 2017, 2018 Free Software Foundation
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
/*
- * Copyright (C) 2017 Free Software Foundation
+ * Copyright (C) 2017, 2018 Free Software Foundation
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
/*
- * Copyright (C) 2016, 2017 Free Software Foundation
+ * Copyright (C) 2016 - 2018 Free Software Foundation
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
/*
- * Copyright (C) 2016, 2017 Free Software Foundation
+ * Copyright (C) 2016 - 2018 Free Software Foundation
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
/*
- * Copyright (C) 2016, 2017 Free Software Foundation
+ * Copyright (C) 2016 - 2018 Free Software Foundation
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
/*
- * Copyright (C) 2016, 2017 Free Software Foundation
+ * Copyright (C) 2016 - 2018 Free Software Foundation
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
/*
- * Copyright (C) 2016, 2017 Free Software Foundation
+ * Copyright (C) 2016 - 2018 Free Software Foundation
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
/*
- * Copyright (C) 2016, 2017 Free Software Foundation
+ * Copyright (C) 2016 - 2018 Free Software Foundation
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
/*
- * Copyright (C) 2016, 2017 Free Software Foundation
+ * Copyright (C) 2016 - 2018 Free Software Foundation
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
/*
- * Copyright (C) 2016, 2017 Free Software Foundation
+ * Copyright (C) 2016 - 2018 Free Software Foundation
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
/*
- * Copyright (C) 2016, 2017 Free Software Foundation
+ * Copyright (C) 2016 - 2018 Free Software Foundation
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
/*
- * Copyright (C) 2016, 2017 Free Software Foundation
+ * Copyright (C) 2016 - 2018 Free Software Foundation
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
/*
- * Copyright (C) 2016, 2017 Free Software Foundation
+ * Copyright (C) 2016 - 2018 Free Software Foundation
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
/*
- * Copyright (C) 2016, 2017 Free Software Foundation
+ * Copyright (C) 2016 - 2018 Free Software Foundation
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
/*
- * Copyright (C) 2016, 2017 Free Software Foundation
+ * Copyright (C) 2016 - 2018 Free Software Foundation
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
/*
- * Copyright (C) 2016, 2017 Free Software Foundation
+ * Copyright (C) 2016 - 2018 Free Software Foundation
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* <p>
* @author Roland Häder<roland@mxchange.org>
*/
-public interface BranchOffice extends Serializable {
+public interface BranchOffice extends Comparable<BranchOffice>, Serializable {
/**
* Getter for branch office's city name
/*
- * Copyright (C) 2017 Free Software Foundation
+ * Copyright (C) 2017, 2018 Free Software Foundation
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
/*
- * Copyright (C) 2016, 2017 Free Software Foundation
+ * Copyright (C) 2016 - 2018 Free Software Foundation
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
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.jcoreee.utils.StringUtils;
import org.mxchange.jcountry.model.data.Country;
import org.mxchange.jcountry.model.data.CountryData;
import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber;
this.branchHouseNumber = branchHouseNumber;
}
+ @Override
+ public int compareTo (final BranchOffice branchOffice) {
+ // For performance reasons
+ if (Objects.equals(this, branchOffice)) {
+ // Same object
+ return 0;
+ }
+
+ // Init check array (I could repeat myself here, but no)
+ final int[] comparators = {
+ // A different branch number is a clear indication ...
+ // A different branch number is a clear indication ...
+ // A different branch number is a clear indication ...
+ // A different branch number is a clear indication ...
+ Long.compare(this.getBranchNumber(), branchOffice.getBranchNumber()),
+ // ... same with id ...
+ Long.compare(this.getBranchId(), branchOffice.getBranchId()),
+ // ... then country
+ this.getBranchCountry().compareTo(branchOffice.getBranchCountry()),
+ // ... next city
+ this.getBranchCity().compareToIgnoreCase(branchOffice.getBranchCity()),
+ // ... then ZIP code
+ this.getBranchZipCode().compareTo(branchOffice.getBranchZipCode()),
+ // ... and street
+ this.getBranchStreet().compareToIgnoreCase(branchOffice.getBranchStreet()),
+ // ... and house number
+ this.getBranchHouseNumber().compareTo(branchOffice.getBranchHouseNumber()),
+ // ... and last house number
+ Short.compare(this.getBranchLastHouseNumber(), branchOffice.getBranchLastHouseNumber()),
+ StringUtils.comareToIgnoreCase(this.getBranchHouseNumberExtension(), branchOffice.getBranchHouseNumberExtension()),
+ // ... store ...
+ Short.compare(this.getBranchStore(), branchOffice.getBranchStore()),
+ // ... suite number ...
+ Short.compare(this.getBranchSuiteNumber(), branchOffice.getBranchSuiteNumber())
+ };
+
+ // Loop through all
+ for (int i = 0; i < comparators.length; i++) {
+
+ // Is it smaller or bigger?
+ if (comparators[i] < 0) {
+ return -1;
+ } else if (comparators[i] > 0) {
+ return 1;
+ }
+ }
+
+ // Verify that compareTo() is constistent with equals()
+ assert Objects.equals(this, branchOffice) : "compareTo inconsistent with equals()"; //NOI18N
+
+ // Assume euqality
+ return 0;
+ }
+
@Override
public boolean equals (final Object object) {
if (null == object) {
return false;
}
+ // @todo Maybe a bit unsafe cast?
final BranchOffice branchOffice = (BranchOffice) object;
if (!Objects.equals(this.getBranchId(), branchOffice.getBranchId())) {
/*
- * Copyright (C) 2016, 2017 Free Software Foundation
+ * Copyright (C) 2016 - 2018 Free Software Foundation
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
/*
- * Copyright (C) 2016, 2017 Free Software Foundation
+ * Copyright (C) 2016 - 2018 Free Software Foundation
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
/*
- * Copyright (C) 2017 Free Software Foundation
+ * Copyright (C) 2017, 2018 Free Software Foundation
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
/*
- * Copyright (C) 2016, 2017 Free Software Foundation
+ * Copyright (C) 2016 - 2018 Free Software Foundation
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
/*
- * Copyright (C) 2016, 2017 Free Software Foundation
+ * Copyright (C) 2016 - 2018 Free Software Foundation
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
/*
- * Copyright (C) 2017 Free Software Foundation
+ * Copyright (C) 2017, 2018 Free Software Foundation
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
/*
- * Copyright (C) 2016, 2017 Free Software Foundation
+ * Copyright (C) 2016 - 2018 Free Software Foundation
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
/*
- * Copyright (C) 2017 Free Software Foundation
+ * Copyright (C) 2017, 2018 Free Software Foundation
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
/*
- * Copyright (C) 2016, 2017 Free Software Foundation
+ * Copyright (C) 2016 - 2018 Free Software Foundation
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
/*
- * Copyright (C) 2016, 2017 Free Software Foundation
+ * Copyright (C) 2016 - 2018 Free Software Foundation
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
/*
- * Copyright (C) 2016, 2017 Free Software Foundation
+ * Copyright (C) 2016 - 2018 Free Software Foundation
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
/*
- * Copyright (C) 2016, 2017 Free Software Foundation
+ * Copyright (C) 2016 - 2018 Free Software Foundation
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
/*
- * Copyright (C) 2016, 2017 Free Software Foundation
+ * Copyright (C) 2016 - 2018 Free Software Foundation
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
/*
- * Copyright (C) 2016, 2017 Free Software Foundation
+ * Copyright (C) 2016 - 2018 Free Software Foundation
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
/*
- * Copyright (C) 2016, 2017 Free Software Foundation
+ * Copyright (C) 2016 - 2018 Free Software Foundation
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by