*/
private static final long serialVersionUID = 2_867_938_676_165_402L;
- public static boolean isSameReceipt (final BillableReceiptItem receiptItem1, final BillableReceiptItem receiptItem2) {
+ /**
+ * Checks if both receipt items are the same by assigned receipt, product
+ * and quantity.
+ * <p>
+ * @param receiptItem1 Receipt item 1
+ * @param receiptItem2 Receipt item 2
+ * <p>
+ * @return Whether both are equal
+ */
+ public static boolean isSameReceiptItem (final BillableReceiptItem receiptItem1, final BillableReceiptItem receiptItem2) {
// Pre-compare both as entities (same id)
if (Objects.equals(receiptItem1, receiptItem2)) {
// Same entity (with id number)
// Validate parameter
if (null == receiptItem1) {
// Throw NPE
- throw new NullPointerException("receiptItem1 is null");
+ throw new NullPointerException("receiptItem1 is null"); //NOI18N
} else if ((receiptItem1.getItemId() instanceof Long) && (receiptItem1.getItemId() < 1)) {
// Throw IAE
- throw new IllegalArgumentException(MessageFormat.format("receiptItem1.itemId={0} is not valid.", receiptItem1.getItemId()));
- } else if (receiptItem1.getItemReceipt()== null) {
+ throw new IllegalArgumentException(MessageFormat.format("receiptItem1.itemId={0} is not valid.", receiptItem1.getItemId())); //NOI18N
+ } else if (receiptItem1.getItemReceipt() == null) {
// Throw NPE
- throw new NullPointerException("receiptItem1.itemReceipt is null");
+ throw new NullPointerException("receiptItem1.itemReceipt is null"); //NOI18N
} else if (receiptItem1.getItemReceipt().getReceiptId() == null) {
// Throw NPE
- throw new NullPointerException("receiptItem1.itemReceipt.receiptId is null");
+ throw new NullPointerException("receiptItem1.itemReceipt.receiptId is null"); //NOI18N
} else if (receiptItem1.getItemReceipt().getReceiptId() < 1) {
// Throw NPE
- throw new NullPointerException(MessageFormat.format("receiptItem1.itemReceipt.receiptId={0} is not valid", receiptItem1.getItemReceipt().getReceiptId()));
+ throw new NullPointerException(MessageFormat.format("receiptItem1.itemReceipt.receiptId={0} is not valid", receiptItem1.getItemReceipt().getReceiptId())); //NOI18N
} else if (receiptItem1.getItemProduct() == null) {
// Throw NPE again
- throw new NullPointerException("receiptItem1.itemProduct is null.");
+ throw new NullPointerException("receiptItem1.itemProduct is null."); //NOI18N
} else if (receiptItem1.getItemProduct().getProductId() == null) {
// Throw NPE again
- throw new NullPointerException("receiptItem1.itemProduct.productId is null.");
+ throw new NullPointerException("receiptItem1.itemProduct.productId is null."); //NOI18N
} else if (receiptItem1.getItemProduct().getProductId() < 1) {
// Throw IAE
- throw new IllegalArgumentException(MessageFormat.format("receiptItem1.itemProduct.productId={0} is invalid.", receiptItem1.getItemProduct().getProductId()));
+ throw new IllegalArgumentException(MessageFormat.format("receiptItem1.itemProduct.productId={0} is invalid.", receiptItem1.getItemProduct().getProductId())); //NOI18N
} else if (null == receiptItem2) {
// Throw NPE
- throw new NullPointerException("receiptItem2 is null");
+ throw new NullPointerException("receiptItem2 is null"); //NOI18N
} else if ((receiptItem2.getItemId() instanceof Long) && (receiptItem2.getItemId() < 1)) {
// Throw IAE
- throw new IllegalArgumentException(MessageFormat.format("receiptItem2.itemId={0} is not valid.", receiptItem2.getItemId()));
- } else if (receiptItem2.getItemReceipt()== null) {
+ throw new IllegalArgumentException(MessageFormat.format("receiptItem2.itemId={0} is not valid.", receiptItem2.getItemId())); //NOI18N
+ } else if (receiptItem2.getItemReceipt() == null) {
// Throw NPE
- throw new NullPointerException("receiptItem2.itemReceipt is null");
+ throw new NullPointerException("receiptItem2.itemReceipt is null"); //NOI18N
} else if (receiptItem2.getItemReceipt().getReceiptId() == null) {
// Throw NPE
- throw new NullPointerException("receiptItem2.itemReceipt.receiptId is null");
+ throw new NullPointerException("receiptItem2.itemReceipt.receiptId is null"); //NOI18N
} else if (receiptItem2.getItemReceipt().getReceiptId() < 1) {
// Throw NPE
- throw new NullPointerException(MessageFormat.format("receiptItem2.itemReceipt.receiptId={0} is not valid", receiptItem2.getItemReceipt().getReceiptId()));
+ throw new NullPointerException(MessageFormat.format("receiptItem2.itemReceipt.receiptId={0} is not valid", receiptItem2.getItemReceipt().getReceiptId())); //NOI18N
} else if (receiptItem2.getItemProduct() == null) {
// Throw NPE again
- throw new NullPointerException("receiptItem2.itemProduct is null.");
+ throw new NullPointerException("receiptItem2.itemProduct is null."); //NOI18N
} else if (receiptItem2.getItemProduct().getProductId() == null) {
// Throw NPE again
- throw new NullPointerException("receiptItem2.itemProduct.productId is null.");
+ throw new NullPointerException("receiptItem2.itemProduct.productId is null."); //NOI18N
} else if (receiptItem2.getItemProduct().getProductId() < 1) {
// Throw IAE
- throw new IllegalArgumentException(MessageFormat.format("receiptItem2.itemProduct.productId={0} is invalid.", receiptItem2.getItemProduct().getProductId()));
+ throw new IllegalArgumentException(MessageFormat.format("receiptItem2.itemProduct.productId={0} is invalid.", receiptItem2.getItemProduct().getProductId())); //NOI18N
} else if (null == receiptItem2) {
// Throw NPE
- throw new NullPointerException("receiptItem2 is null");
+ throw new NullPointerException("receiptItem2 is null"); //NOI18N
}
// Now check all individually