import fish.payara.cdi.jsr107.impl.NamedCache;
import java.text.MessageFormat;
import java.util.Comparator;
-import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import javax.annotation.PostConstruct;
// Is the list empty, but filled cache?
if (this.getAllReceipts().isEmpty() && this.receiptCache.iterator().hasNext()) {
- // Get iterator
- final Iterator<Cache.Entry<Long, BillableReceipt>> iterator = this.receiptCache.iterator();
-
// Build up list
- while (iterator.hasNext()) {
- // GEt next element
- final Cache.Entry<Long, BillableReceipt> next = iterator.next();
-
+ for (final Cache.Entry<Long, BillableReceipt> currentEntry : this.receiptCache) {
// Add to list
- this.getAllReceipts().add(next.getValue());
+ this.getAllReceipts().add(currentEntry.getValue());
}
// Sort list
this.getAllReceipts().sort(new Comparator<BillableReceipt>() {
@Override
- public int compare (final BillableReceipt o1, final BillableReceipt o2) {
- return o1.getReceiptId() > o2.getReceiptId() ? 1 : o1.getReceiptId() < o2.getReceiptId() ? -1 : 0;
+ public int compare (final BillableReceipt receipt1, final BillableReceipt receipt2) {
+ return receipt1.getReceiptId() > receipt2.getReceiptId() ? 1 : receipt1.getReceiptId() < receipt2.getReceiptId() ? -1 : 0;
}
}
);
import fish.payara.cdi.jsr107.impl.NamedCache;
import java.text.MessageFormat;
import java.util.Comparator;
-import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Objects;
// Is the list empty, but filled cache?
if (this.getAllReceiptItems().isEmpty() && this.receiptItemCache.iterator().hasNext()) {
- // Get iterator
- final Iterator<Cache.Entry<Long, BillableReceiptItem>> iterator = this.receiptItemCache.iterator();
-
// Build up list
- while (iterator.hasNext()) {
- // GEt next element
- final Cache.Entry<Long, BillableReceiptItem> next = iterator.next();
-
+ for (final Cache.Entry<Long, BillableReceiptItem> currentEntry : this.receiptItemCache) {
// Add to list
- this.getAllReceiptItems().add(next.getValue());
+ this.getAllReceiptItems().add(currentEntry.getValue());
}
// Sort list
this.getAllReceiptItems().sort(new Comparator<BillableReceiptItem>() {
@Override
- public int compare (final BillableReceiptItem o1, final BillableReceiptItem o2) {
- return o1.getItemId() > o2.getItemId() ? 1 : o1.getItemId() < o2.getItemId() ? -1 : 0;
+ public int compare (final BillableReceiptItem receiptItem1, final BillableReceiptItem receiptItem2) {
+ return receiptItem1.getItemId() > receiptItem2.getItemId() ? 1 : receiptItem1.getItemId() < receiptItem2.getItemId() ? -1 : 0;
}
}
);
return true;
}
- // Get iterator from list
- final Iterator<BillableReceiptItem> iterator = this.getAllReceiptItems().iterator();
-
// Default is not the same
boolean alreadyAdded = false;
// Loop over all
- while (iterator.hasNext()) {
- // Get current item
- final BillableReceiptItem item = iterator.next();
-
+ for (final BillableReceiptItem item : this.getAllReceiptItems()) {
// Is the same?
if (ReceiptItems.isSameReceiptItem(item, receiptItem)) {
// Yes, found it