return receipt1.compareTo(receipt2);
}
+ /**
+ * Copies all fields from source receipt to target receipt.
+ * <p>
+ * @param sourceReceipt Source receipt instance
+ * @param targetReceipt Target Receipt instance
+ */
+ public static void copyAll (final BillableReceipt sourceReceipt, final BillableReceipt targetReceipt) {
+ // Both should not be null
+ if (null == sourceReceipt) {
+ // Throw NPE
+ throw new NullPointerException("sourceReceipt is null"); //NOI18N
+ } else if (null == targetReceipt) {
+ // Throw NPE
+ throw new NullPointerException("targetReceipt is null"); //NOI18N
+ } else if (Objects.equals(sourceReceipt, targetReceipt)) {
+ // Is exactly the same!
+ throw new IllegalArgumentException("sourcerReceipt and targetReceipt are the same."); //NOI18N
+ }
+
+ // Copy all fields
+ targetReceipt.setReceiptBarCodeNumber(sourceReceipt.getReceiptBarCodeNumber());
+ targetReceipt.setReceiptBonusCard(sourceReceipt.getReceiptBonusCard());
+ targetReceipt.setReceiptBranchOffice(sourceReceipt.getReceiptBranchOffice());
+ targetReceipt.setReceiptCreated(sourceReceipt.getReceiptCreated());
+ targetReceipt.setReceiptId(sourceReceipt.getReceiptId());
+ targetReceipt.setReceiptIssued(sourceReceipt.getReceiptIssued());
+ targetReceipt.setReceiptNumber(sourceReceipt.getReceiptNumber());
+ targetReceipt.setReceiptPaymentType(sourceReceipt.getReceiptPaymentType());
+ targetReceipt.setReceiptRegisterNumber(sourceReceipt.getReceiptRegisterNumber());
+ targetReceipt.setReceiptSellerEmployee(sourceReceipt.getReceiptSellerEmployee());
+ targetReceipt.setReceiptSequenceNumber(sourceReceipt.getReceiptSequenceNumber());
+ targetReceipt.setReceiptTransactionNumber(sourceReceipt.getReceiptTransactionNumber());
+ targetReceipt.setReceiptUpdated(sourceReceipt.getReceiptUpdated());
+ targetReceipt.setReceiptUser(sourceReceipt.getReceiptUser());
+ }
+
/**
* Checks whether both receipts are the same, means not true entity equality
* but if the receipt in general terms does already exist. A pre-check on
// Validate parameter
if (null == receipt1) {
// Throw NPE
- throw new NullPointerException("receipt1 is null");
+ throw new NullPointerException("receipt1 is null"); //NOI18N
} else if ((receipt1.getReceiptId() instanceof Long) && (receipt1.getReceiptId() < 1)) {
// Throw IAE
- throw new IllegalArgumentException(MessageFormat.format("receipt1.receiptId={0} is not valid.", receipt1.getReceiptId()));
+ throw new IllegalArgumentException(MessageFormat.format("receipt1.receiptId={0} is not valid.", receipt1.getReceiptId())); //NOI18N
} else if (receipt1.getReceiptBranchOffice() == null) {
// Throw NPE
- throw new NullPointerException("receipt1.receiptBranchOffice is null");
+ throw new NullPointerException("receipt1.receiptBranchOffice is null"); //NOI18N
} else if (receipt1.getReceiptBranchOffice().getBranchId() == null) {
// Throw NPE
- throw new NullPointerException("receipt1.receiptBranchOffice.branchId is null");
+ throw new NullPointerException("receipt1.receiptBranchOffice.branchId is null"); //NOI18N
} else if (receipt1.getReceiptBranchOffice().getBranchId() < 1) {
// Throw NPE
- throw new NullPointerException(MessageFormat.format("receipt1.receiptBranchOffice.branchId={0} is not valid", receipt1.getReceiptBranchOffice().getBranchId()));
+ throw new NullPointerException(MessageFormat.format("receipt1.receiptBranchOffice.branchId={0} is not valid", receipt1.getReceiptBranchOffice().getBranchId())); //NOI18N
} else if ((receipt1.getReceiptNumber() != null) && (receipt1.getReceiptNumber().isEmpty())) {
// Throw IAE
- throw new IllegalArgumentException("receipt1.receiptNumber is empty.");
+ throw new IllegalArgumentException("receipt1.receiptNumber is empty."); //NOI18N
} else if (receipt1.getReceiptPaymentType() == null) {
// Throw NPE
- throw new NullPointerException("receipt1.receiptPaymentType is null");
+ throw new NullPointerException("receipt1.receiptPaymentType is null"); //NOI18N
} else if (null == receipt2) {
// Throw NPE
- throw new NullPointerException("receipt2 is null");
+ throw new NullPointerException("receipt2 is null"); //NOI18N
} else if ((receipt2.getReceiptId() instanceof Long) && (receipt2.getReceiptId() < 1)) {
// Throw IAE
- throw new IllegalArgumentException(MessageFormat.format("receipt2.receiptId={0} is not valid.", receipt2.getReceiptId()));
+ throw new IllegalArgumentException(MessageFormat.format("receipt2.receiptId={0} is not valid.", receipt2.getReceiptId())); //NOI18N
} else if (receipt2.getReceiptBranchOffice() == null) {
// Throw NPE
- throw new NullPointerException("receipt2.receiptBranchOffice is null");
+ throw new NullPointerException("receipt2.receiptBranchOffice is null"); //NOI18N
} else if (receipt2.getReceiptBranchOffice().getBranchId() == null) {
// Throw NPE
- throw new NullPointerException("receipt2.receiptBranchOffice.branchId is null");
+ throw new NullPointerException("receipt2.receiptBranchOffice.branchId is null"); //NOI18N
} else if (receipt2.getReceiptBranchOffice().getBranchId() < 1) {
// Throw NPE
- throw new NullPointerException(MessageFormat.format("receipt2.receiptBranchOffice.branchId={0} is not valid", receipt2.getReceiptBranchOffice().getBranchId()));
+ throw new NullPointerException(MessageFormat.format("receipt2.receiptBranchOffice.branchId={0} is not valid", receipt2.getReceiptBranchOffice().getBranchId())); //NOI18N
} else if ((receipt2.getReceiptNumber() != null) && (receipt2.getReceiptNumber().isEmpty())) {
// Throw IAE
- throw new IllegalArgumentException("receipt2.receiptNumber is empty.");
+ throw new IllegalArgumentException("receipt2.receiptNumber is empty."); //NOI18N
} else if (receipt2.getReceiptPaymentType() == null) {
// Throw NPE
- throw new NullPointerException("receipt2.receiptPaymentType is null");
+ throw new NullPointerException("receipt2.receiptPaymentType is null"); //NOI18N
}
// Now check all individually