+ /**
+ * Compares both receipt instances. This method returns -1 if second
+ * instance is null.
+ * <p>
+ * @param receipt1 BillableReceipt instance 1
+ * @param receipt2 BillableReceipt instance 2
+ * <p>
+ * @return Comparison value
+ */
+ public static int compare (final BillableReceipt receipt1, final BillableReceipt receipt2) {
+ // Check euqality, then at least first must be given
+ if (Objects.equals(receipt1, receipt2)) {
+ // Both are same
+ return 0;
+ } else if (null == receipt1) {
+ // First is null
+ return -1;
+ } else if (null == receipt2) {
+ // Second is null
+ return 1;
+ }
+
+ // Invoke compareTo() method
+ return receipt1.compareTo(receipt2);
+ }
+
+ /**
+ * 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
+ * entity equality is however performed to avoid below much longer code.
+ * <p>
+ * @param receipt1 BillableReceipt instance 1
+ * @param receipt2 BillableReceipt instance 2
+ * <p>
+ * @return Whether both receipts are the same (not instances)
+ */