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.getAllProducts().isEmpty() && this.productCache.iterator().hasNext()) {
- // Get iterator
- final Iterator<Cache.Entry<Long, Product>> iterator = this.productCache.iterator();
-
// Build up list
- while (iterator.hasNext()) {
- // GEt next element
- final Cache.Entry<Long, Product> next = iterator.next();
-
+ for (final Cache.Entry<Long, Product> currentEntry : this.productCache) {
// Add to list
- this.getAllProducts().add(next.getValue());
+ this.getAllProducts().add(currentEntry.getValue());
}
// Sort list
this.getAllProducts().sort(new Comparator<Product>() {
@Override
- public int compare (final Product o1, final Product o2) {
- return o1.getProductId() > o2.getProductId() ? 1 : o1.getProductId() < o2.getProductId() ? -1 : 0;
+ public int compare (final Product product1, final Product product2) {
+ return product1.getProductId() > product2.getProductId() ? 1 : product1.getProductId() < product2.getProductId() ? -1 : 0;
}
}
);
/**
* Adds unique instance to product list. First any existing instance is
- * being removed, then the new instance is added. It also updates the
- * cache regardless if found or not.
+ * being removed, then the new instance is added. It also updates the cache
+ * regardless if found or not.
* <p>
* @param product Product instance to add uniquely
*/
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.allCategories.isEmpty() && this.categoryCache.iterator().hasNext()) {
- // Get iterator
- final Iterator<Cache.Entry<Long, Category>> iterator = this.categoryCache.iterator();
-
// Build up list
- while (iterator.hasNext()) {
- // GEt next element
- final Cache.Entry<Long, Category> next = iterator.next();
-
+ for (final Cache.Entry<Long, Category> currentEntry : this.categoryCache) {
// Add to list
- this.allCategories.add(next.getValue());
+ this.allCategories.add(currentEntry.getValue());
}
// Sort list
this.allCategories.sort(new Comparator<Category>() {
@Override
- public int compare (final Category o1, final Category o2) {
- return o1.getCategoryId() > o2.getCategoryId() ? 1 : o1.getCategoryId() < o2.getCategoryId() ? -1 : 0;
+ public int compare (final Category category1, final Category category2) {
+ return category1.getCategoryId() > category2.getCategoryId() ? 1 : category1.getCategoryId() < category2.getCategoryId() ? -1 : 0;
}
}
);