|
5 | 5 | import de.codecentric.java8examples.Person; |
6 | 6 |
|
7 | 7 | import java.math.BigDecimal; |
| 8 | +import java.util.AbstractMap.SimpleEntry; |
8 | 9 | import java.util.*; |
| 10 | +import java.util.function.Function; |
9 | 11 | import java.util.stream.Collectors; |
10 | 12 |
|
11 | 13 | /** |
@@ -91,7 +93,7 @@ public static Map<String, String> cheapestDealersByProduct(List<Invoice> invoice |
91 | 93 | /** |
92 | 94 | * From a given list of invoices, compute for every dealer the available products together with its price. |
93 | 95 | */ |
94 | | - public static Map<String, ProductWithPrice> computeDealerInventory(List<Invoice> invoices) { |
| 96 | + public static Map<String, List<ProductWithPrice>> computeDealerInventory(List<Invoice> invoices) { |
95 | 97 | return Collections.emptyMap(); |
96 | 98 | } |
97 | 99 |
|
@@ -121,6 +123,34 @@ public String getProductName() { |
121 | 123 | public BigDecimal getPrice() { |
122 | 124 | return price; |
123 | 125 | } |
| 126 | + |
| 127 | + @Override |
| 128 | + public boolean equals(Object o) { |
| 129 | + if (this == o) return true; |
| 130 | + if (o == null || getClass() != o.getClass()) return false; |
| 131 | + |
| 132 | + ProductWithPrice that = (ProductWithPrice) o; |
| 133 | + |
| 134 | + if (price != null ? !price.equals(that.price) : that.price != null) return false; |
| 135 | + if (productName != null ? !productName.equals(that.productName) : that.productName != null) return false; |
| 136 | + |
| 137 | + return true; |
| 138 | + } |
| 139 | + |
| 140 | + @Override |
| 141 | + public int hashCode() { |
| 142 | + int result = productName != null ? productName.hashCode() : 0; |
| 143 | + result = 31 * result + (price != null ? price.hashCode() : 0); |
| 144 | + return result; |
| 145 | + } |
| 146 | + |
| 147 | + @Override |
| 148 | + public String toString() { |
| 149 | + return "ProductWithPrice{" + |
| 150 | + "productName='" + productName + '\'' + |
| 151 | + ", price=" + price + |
| 152 | + '}'; |
| 153 | + } |
124 | 154 | } |
125 | 155 |
|
126 | 156 | } |
0 commit comments