*/
package org.mxchange.jaddressbook.model.addressbook;
+import java.text.MessageFormat;
import java.util.Date;
import java.util.Objects;
import javax.persistence.Basic;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
+import org.apache.commons.lang3.StringUtils;
import org.mxchange.jaddressbook.model.addressbook.status.AddressbokStatus;
import org.mxchange.jcoreutils.comparable.ComparableUtils;
+import org.mxchange.jcoreutils.enums.EnumUtils;
import org.mxchange.jusercore.model.user.LoginUser;
import org.mxchange.jusercore.model.user.User;
import org.mxchange.jusercore.model.utils.UserUtils;
// Invoke default constructor
this();
+ // Check all parameters
+ if (null == addressbookName) {
+ // Throw NPE
+ throw new NullPointerException("Parameter 'addressbookName' is null"); //NOI18N
+ } else if (addressbookName.isEmpty()) {
+ // Throw IAE
+ throw new IllegalArgumentException("Parameter 'addressbookName' is empty"); //NOI18N
+ } else if (null == addressbookUser) {
+ // Throw NPE again
+ throw new NullPointerException("Parameter 'addressbookUser' is null"); //NOI18N
+ } else if (addressbookUser.getUserId() == null) {
+ // Throw it again
+ throw new NullPointerException("addressbookUser.userId is null"); //NOI18N
+ } else if (addressbookUser.getUserId() < 1) {
+ // Throw IAE again
+ throw new IllegalArgumentException(MessageFormat.format("addressbookUser.userId={0} is invalid", addressbookUser.getUserId())); //NOI18N
+ }
+
// Set name and user instance
this.addressbookName = addressbookName;
this.addressbookUser = addressbookUser;
// All comparators
final int comparators[] = {
// First name ...
- this.getAddressbookName().compareToIgnoreCase(addressbook.getAddressbookName()),
+ StringUtils.compare(this.getAddressbookName(), addressbook.getAddressbookName()),
// ... status
- this.getAddressbookStatus().compareTo(addressbook.getAddressbookStatus()),
+ EnumUtils.compare(this.getAddressbookStatus(), addressbook.getAddressbookStatus()),
// .. then user
UserUtils.compare(this.getAddressbookUser(), addressbook.getAddressbookUser())
};