excludes=
file.reference.jcontacts-business-core.jar=lib/jcontacts-business-core.jar
file.reference.jcontacts-core.jar=lib/jcontacts-core.jar
-file.reference.jcoreee.jar=lib/jcoreee.jar
+file.reference.jcore-utils.jar=lib/jcore-utils.jar
file.reference.jcountry-core.jar=lib/jcountry-core.jar
file.reference.jcustomer-core.jar=lib/jcustomer-core.jar
file.reference.jphone-core.jar=lib/jphone-core.jar
jar.compress=false
jar.index=${jnlp.enabled}
javac.classpath=\
- ${file.reference.jcoreee.jar}:\
${file.reference.jcountry-core.jar}:\
${file.reference.jphone-core.jar}:\
${file.reference.juser-core.jar}:\
${file.reference.jcontacts-business-core.jar}:\
${file.reference.jcustomer-core.jar}:\
${file.reference.jproduct-core.jar}:\
+ ${file.reference.jcore-utils.jar}:\
+ ${libs.commons-lang3.classpath}:\
${libs.jpa20-persistence.classpath}:\
${libs.javaee-api-7.0.classpath}
# Space-separated list of extra javac options
source.encoding=UTF-8
source.reference.jcontacts-business-core.jar=../jcontacts-business-core/src/
source.reference.jcontacts-core.jar=../jcontacts-core/src/
-source.reference.jcoreee.jar=../jcoreee/src/
+source.reference.jcore-utils.jar=../jcore-utils/src/
source.reference.jcountry-core.jar=../jcountry-core/src/
source.reference.jcustomer-core.jar=../jcustomer-core/src/
source.reference.jphone-core.jar=../jphone-core/src/
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
+import org.apache.commons.lang3.StringUtils;
import org.mxchange.jcontacts.model.contact.Contact;
+import org.mxchange.jcontacts.model.contact.Contacts;
import org.mxchange.jcontacts.model.contact.UserContact;
import org.mxchange.jcontactsbusiness.model.basicdata.BasicData;
+import org.mxchange.jcontactsbusiness.model.basicdata.BasicDataUtils;
import org.mxchange.jcontactsbusiness.model.basicdata.BusinessBasicData;
+import org.mxchange.jcoreutils.Comparables;
import org.mxchange.jcustomercore.model.customer.ContactCustomer;
import org.mxchange.jcustomercore.model.customer.Customer;
+import org.mxchange.jcustomercore.utils.Customers;
/**
* A POJO (entity) for bonus cards
* Constructor with all required fields
* <p>
* @param bonusCardContact Contact instance
+ * @param bonusCardIssuer Issuing company instance
*/
- public FinancialBonusCard (final Contact bonusCardContact) {
+ public FinancialBonusCard (final Contact bonusCardContact, final BasicData bonusCardIssuer) {
// Call other constructor first
this();
// Throw it again
throw new NullPointerException("bonusCardContact.contactId is null"); //NOI18N
} else if (bonusCardContact.getContactId() < 1) {
+ // Throw IAE
+ throw new IllegalArgumentException(MessageFormat.format("bonusCardContact.contactId={0} is invalid", bonusCardContact.getContactId())); //NOI18N
+ } else if (null == bonusCardIssuer) {
+ // Throw NPE
+ throw new NullPointerException("bonusCardOwner is null"); //NOI18N
+ } else if (bonusCardIssuer.getBasicDataId() == null) {
// Throw it again
- throw new NullPointerException(MessageFormat.format("bonusCardContact.contactId={0} is invalid", bonusCardContact.getContactId())); //NOI18N
+ throw new NullPointerException("bonusCardOwner.baseDataId is null"); //NOI18N
+ } else if (bonusCardIssuer.getBasicDataId() < 1) {
+ // Throw IAE
+ throw new IllegalArgumentException(MessageFormat.format("bonusCardOwner.baseDataId={0} is invalid", bonusCardIssuer.getBasicDataId())); //NOI18N
}
// Set all
this.bonusCardContact = bonusCardContact;
+ this.bonusCardIssuer = bonusCardIssuer;
+ }
+
+ @Override
+ public int compareTo (final BonusCard bonusCard) {
+ // For performance reasons
+ if (null == bonusCard) {
+ // Should not happen
+ throw new NullPointerException("bonusCard is null"); //NOI18N
+ } else if (Objects.equals(this, bonusCard)) {
+ // Same object
+ return 0;
+ }
+
+ // Init comparators
+ final int comparators[] = {
+ // First compare by number
+ StringUtils.compare(this.getBonusCardNumber(), bonusCard.getBonusCardNumber()),
+ // ... next by bar code
+ StringUtils.compare(this.getBonusCardBarCode(), bonusCard.getBonusCardBarCode()),
+ // ... customer data
+ Customers.compare(this.getBonusCardCustomer(), bonusCard.getBonusCardCustomer()),
+ // ... contact data (card holder)
+ Contacts.compare(this.getBonusCardContact(), bonusCard.getBonusCardContact()),
+ // ... issuing company data
+ this.getBonusCardIssuer().compareTo(bonusCard.getBonusCardIssuer()),
+ // ... partner company data
+ BasicDataUtils.compare(this.getBonusCardPartner(), bonusCard.getBonusCardPartner())
+ };
+
+ // Check all values
+ final int comparison = Comparables.checkAll(comparators);
+
+ // Return value
+ return comparison;
}
@Override