|
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 | /** |
@@ -117,7 +119,7 @@ public static Map<String, String> cheapestDealersByProduct(List<Invoice> invoice |
117 | 119 | /** |
118 | 120 | * From a given list of invoices, compute for every dealer the available products together with its price. |
119 | 121 | */ |
120 | | - public static Map<String, ProductWithPrice> computeDealerInventory(List<Invoice> invoices) { |
| 122 | + public static Map<String, List<ProductWithPrice>> computeDealerInventory(List<Invoice> invoices) { |
121 | 123 | return Collections.emptyMap(); |
122 | 124 | } |
123 | 125 |
|
@@ -147,6 +149,34 @@ public String getProductName() { |
147 | 149 | public BigDecimal getPrice() { |
148 | 150 | return price; |
149 | 151 | } |
| 152 | + |
| 153 | + @Override |
| 154 | + public boolean equals(Object o) { |
| 155 | + if (this == o) return true; |
| 156 | + if (o == null || getClass() != o.getClass()) return false; |
| 157 | + |
| 158 | + ProductWithPrice that = (ProductWithPrice) o; |
| 159 | + |
| 160 | + if (price != null ? !price.equals(that.price) : that.price != null) return false; |
| 161 | + if (productName != null ? !productName.equals(that.productName) : that.productName != null) return false; |
| 162 | + |
| 163 | + return true; |
| 164 | + } |
| 165 | + |
| 166 | + @Override |
| 167 | + public int hashCode() { |
| 168 | + int result = productName != null ? productName.hashCode() : 0; |
| 169 | + result = 31 * result + (price != null ? price.hashCode() : 0); |
| 170 | + return result; |
| 171 | + } |
| 172 | + |
| 173 | + @Override |
| 174 | + public String toString() { |
| 175 | + return "ProductWithPrice{" + |
| 176 | + "productName='" + productName + '\'' + |
| 177 | + ", price=" + price + |
| 178 | + '}'; |
| 179 | + } |
150 | 180 | } |
151 | 181 |
|
152 | 182 | } |
0 commit comments