@Override
public int compareTo (final BonusCard bonusCard) {
- // For performance reasons
+ // Check parameter on null-reference and equality to this
if (null == bonusCard) {
// Should not happen
throw new NullPointerException("bonusCard is null"); //NOI18N
- } else if (Objects.equals(this, bonusCard)) {
+ } else if (bonusCard.equals(this)) {
// Same object
return 0;
}
package org.mxchange.jfinancials.model.income;
import java.io.Serializable;
+import java.math.BigDecimal;
import java.util.Date;
import org.mxchange.jfinancials.model.income.interval.FinancialInterval;
import org.mxchange.jusercore.model.user.User;
* <p>
* @author Roland Häder<roland@mxchange.org>
*/
-public interface BillableIncome extends Serializable {
+public interface BillableIncome extends Comparable<BillableIncome>, Serializable {
/**
* Getter for income id (primary key)
* <p>
* @return Income single amount
*/
- Float getIncomeSingleAmount ();
+ BigDecimal getIncomeSingleAmount ();
/**
* Setter for income single amount
* <p>
* @param incomeSingleAmount Income single amount
*/
- void setIncomeSingleAmount (final Float incomeSingleAmount);
+ void setIncomeSingleAmount (final BigDecimal incomeSingleAmount);
/**
* Getter for income title
*/
package org.mxchange.jfinancials.model.income;
+import java.math.BigDecimal;
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.mxchange.jcoreutils.Comparables;
import org.mxchange.jfinancials.model.income.interval.FinancialInterval;
import org.mxchange.jusercore.model.user.LoginUser;
import org.mxchange.jusercore.model.user.User;
*/
@Basic (optional = false)
@Column (name = "income_single_amount", nullable = false)
- private Float incomeSingleAmount;
+ private BigDecimal incomeSingleAmount;
/**
* Income title
* @param incomeInterval Interval
* @param incomeUser Connected user
*/
- public FinancialIncome (final String incomeTitle, final Float incomeSingleAmount, final FinancialInterval incomeInterval, final User incomeUser) {
+ public FinancialIncome (final String incomeTitle, final BigDecimal incomeSingleAmount, final FinancialInterval incomeInterval, final User incomeUser) {
// Call default constructor
this();
this.incomeEnabled = Boolean.TRUE;
}
+ @Override
+ public int compareTo (final BillableIncome billableIncome) {
+ // Check parameter on null-reference and equality to this
+ if (null == billableIncome) {
+ // Should not happen
+ throw new NullPointerException("billableIncome is null"); //NOI18N
+ } else if (billableIncome.equals(this)) {
+ // Same object
+ return 0;
+ }
+
+ // Init comparators
+ final int comparators[] = {
+ // First compare title
+ this.getIncomeTitle().compareToIgnoreCase(billableIncome.getIncomeTitle()),
+ // ... then compare interval
+ this.getIncomeInterval().compareTo(billableIncome.getIncomeInterval()),
+ // ... value
+ this.getIncomeSingleAmount().compareTo(billableIncome.getIncomeSingleAmount()),
+ // ... user instance
+ this.getIncomeUser().compareTo(billableIncome.getIncomeUser())
+ };
+
+ // Check all values
+ final int comparison = Comparables.checkAll(comparators);
+
+ // Return value
+ return comparison;
+ }
+
@Override
public boolean equals (final Object object) {
if (this == object) {
}
@Override
- public void setIncomeInterval (FinancialInterval incomeInterval) {
+ public void setIncomeInterval (final FinancialInterval incomeInterval) {
this.incomeInterval = incomeInterval;
}
@Override
- public Float getIncomeSingleAmount () {
+ public BigDecimal getIncomeSingleAmount () {
return this.incomeSingleAmount;
}
@Override
- public void setIncomeSingleAmount (Float incomeSingleAmount) {
+ public void setIncomeSingleAmount (final BigDecimal incomeSingleAmount) {
this.incomeSingleAmount = incomeSingleAmount;
}
* <p>
* @author Roland Häder<roland@mxchange.org>
*/
-public interface BillableReceipt extends Serializable {
+public interface BillableReceipt extends Comparable<BillableReceipt>, Serializable {
/**
* Getter for receipt bar-code number
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
+import org.apache.commons.lang3.StringUtils;
import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice;
+import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffices;
import org.mxchange.jcontactsbusiness.model.branchoffice.BusinessBranchOffice;
import org.mxchange.jcontactsbusiness.model.employee.BusinessEmployee;
import org.mxchange.jcontactsbusiness.model.employee.Employable;
+import org.mxchange.jcontactsbusiness.model.employee.Employees;
+import org.mxchange.jcoreutils.Comparables;
+import org.mxchange.jcoreutils.SafeNumberUtils;
import org.mxchange.jfinancials.model.bonus_card.BonusCard;
import org.mxchange.jfinancials.model.bonus_card.FinancialBonusCard;
import org.mxchange.jproduct.model.payment.PaymentType;
import org.mxchange.jusercore.model.user.LoginUser;
import org.mxchange.jusercore.model.user.User;
+import org.mxchange.jusercore.model.user.Users;
/**
*
this.receiptIssued = receiptIssued;
}
+ @Override
+ public int compareTo (final BillableReceipt billableReceipt) {
+ // Check parameter on null-reference and equality to this
+ if (null == billableReceipt) {
+ // Should not happen
+ throw new NullPointerException("billableReceipt is null"); //NOI18N
+ } else if (billableReceipt.equals(this)) {
+ // Same object
+ return 0;
+ }
+
+ // Init comparators
+ final int comparators[] = {
+ // First compare receipt number
+ StringUtils.compare(this.getReceiptNumber(), billableReceipt.getReceiptNumber()),
+ // ... next bar-code
+ StringUtils.compare(this.getReceiptBarCodeNumber(), billableReceipt.getReceiptBarCodeNumber()),
+ // ... sequence number
+ SafeNumberUtils.compare(this.getReceiptSequenceNumber(), billableReceipt.getReceiptSequenceNumber()),
+ // ... payment type
+ this.getReceiptPaymentType().compareTo(billableReceipt.getReceiptPaymentType()),
+ // ... register number
+ SafeNumberUtils.compare(this.getReceiptRegisterNumber(), billableReceipt.getReceiptRegisterNumber()),
+ // ... issue date
+ this.getReceiptIssued().compareTo(billableReceipt.getReceiptIssued()),
+ // ... next is seller instance
+ Employees.compare(this.getReceiptSellerEmployee(), billableReceipt.getReceiptSellerEmployee()),
+ // .. branch office
+ BranchOffices.compare(this.getReceiptBranchOffice(), billableReceipt.getReceiptBranchOffice()),
+ // ... and user instance
+ Users.compare(this.getReceiptUser(), billableReceipt.getReceiptUser())
+ };
+
+ // Check all values
+ final int comparison = Comparables.checkAll(comparators);
+
+ // Return value
+ return comparison;
+ }
+
@Override
public boolean equals (final Object object) {
if (this == object) {
* <p>
* @author Roland Häder<roland@mxchange.org>
*/
-public interface BillableReceiptItem extends Serializable {
+public interface BillableReceiptItem extends Comparable<BillableReceiptItem>, Serializable {
/**
* Getter for item's product category
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
+import org.apache.commons.lang3.StringUtils;
import org.mxchange.jcontactsbusiness.model.basicdata.BasicData;
import org.mxchange.jcontactsbusiness.model.basicdata.BusinessBasicData;
+import org.mxchange.jcoreutils.Comparables;
+import org.mxchange.jcoreutils.SafeNumberUtils;
import org.mxchange.jfinancials.model.receipt.BillableReceipt;
import org.mxchange.jfinancials.model.receipt.FinancialReceipt;
import org.mxchange.jproduct.model.category.Category;
import org.mxchange.jproduct.model.category.ProductCategory;
import org.mxchange.jproduct.model.product.GenericProduct;
import org.mxchange.jproduct.model.product.Product;
+import org.mxchange.jproduct.model.product.Products;
/**
* A POJO for receipt items
this.itemReceipt = itemReceipt;
}
+ @Override
+ public int compareTo (final BillableReceiptItem billableReceiptItem) {
+ // Check parameter on null-reference and equality to this
+ if (null == billableReceiptItem) {
+ // Should not happen
+ throw new NullPointerException("billableReceiptItem is null"); //NOI18N
+ } else if (billableReceiptItem.equals(this)) {
+ // Same object
+ return 0;
+ }
+
+ // Init comparators
+ final int comparators[] = {
+ // First check brand name ...
+ StringUtils.compare(this.getItemBrandName(), billableReceiptItem.getItemBrandName()),
+ // ... item number
+ SafeNumberUtils.compare(this.getItemNumber(), billableReceiptItem.getItemNumber()),
+ // ... coupon number
+ StringUtils.compare(this.getItemCouponNumber(), billableReceiptItem.getItemCouponNumber()),
+ // ... gross price
+ SafeNumberUtils.compare(this.getItemGrossPrice(), billableReceiptItem.getItemGrossPrice()),
+ // ... net price
+ SafeNumberUtils.compare(this.getItemNetPrice(), billableReceiptItem.getItemNetPrice()),
+ // ... tax rate
+ SafeNumberUtils.compare(this.getItemTaxRate(), billableReceiptItem.getItemTaxRate()),
+ // ... product quanity
+ this.getItemProductQuantity().compareTo(billableReceiptItem.getItemProductQuantity()),
+ // ... product instance
+ Products.compare(this.getItemProduct(), billableReceiptItem.getItemProduct()),
+ };
+
+ // Check all values
+ final int comparison = Comparables.checkAll(comparators);
+
+ // Return value
+ return comparison;
+ }
+
@Override
public boolean equals (final Object object) {
if (this == object) {