I have set up a maven project. I am running it in Eclipse IDE but it throws an error:
I have already tried mvn clean and mvn eclipse: eclipse from scratch.
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.amazon.mws.finances._2015_05_01.model.ShipmentEvent;
import com.amazon.mws.finances._2015_05_01.model.ShipmentItem;
import com.sun.tools.javac.util.Pair;
public Map<String, BigDecimal> getRefundEventFinancialSummary(ShipmentEvent shipmentEvent) {
Map<String, BigDecimal> chargeMap = new HashMap<>();
List<ShipmentItem> refundItemsList = shipmentEvent.getShipmentItemAdjustmentList();
List<Pair<String, BigDecimal>> accountedCostsList = refundItemsList.stream().map(this::getAccountedCosts)
.flatMap(List::stream).collect(Collectors.toList());
for (Pair<String, BigDecimal> pair : accountedCostsList) {
String keyString = pair.getKey();
if (chargeMap.containsKey(keyString)) {
chargeMap.replace(keyString, chargeMap.get(keyString).add(pair.getValue()));
} else {
chargeMap.put(keyString, pair.getValue());
}
}
return chargeMap;
}
I don't see any issue with the logic but it throws this error:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
The method getKey() is undefined for the type Pair<String,BigDecimal>
The method getValue() is undefined for the type Pair<String,BigDecimal>
The method getValue() is undefined for the type Pair<String,BigDecimal>
Please help me what could be the possible issue? Is it an eclipse problem?
Edit: Added the import statements.