Skip to content

Commit 61c785c

Browse files
Fixed the way the read-only lists and maps are returned from the Menu and OrderImpl classes.
1 parent 0aea45e commit 61c785c

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/main/java/coreapi/Menu.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public float getPrice()
5656
*/
5757
public List<Product> getProductsInMenu()
5858
{
59-
return Collections.unmodifiableList(new ArrayList<Product>(productsMenu.keySet()));
59+
return List.copyOf(new ArrayList<Product>(productsMenu.keySet()));
6060
}
6161
/**
6262
* Returns how much of a product is contained in this menu.

src/main/java/coreapi/OrderImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public BigDecimal totalCost()
9191
*/
9292
public List<Product> getProducts()
9393
{
94-
return Collections.unmodifiableList(new ArrayList<Product>(basket.keySet()));
94+
return List.copyOf(new ArrayList<Product>(basket.keySet()));
9595
}
9696

9797
/**
@@ -101,7 +101,7 @@ public List<Product> getProducts()
101101
*/
102102
public Map<Product,Integer> getBasket()
103103
{
104-
return Collections.unmodifiableMap(basket);
104+
return Map.copyOf(basket);
105105
}
106106

107107
/**

0 commit comments

Comments
 (0)