I'm having trouble following the below code snippet:
prices = pricesService.getProductsByCategory(category);
List<Double> discountedPrices =
Lists.newArrayList(Iterables.transform(prices, new Function<Double, Double>() {
public Double apply(final Double from) {
return from *.88;
}
}));
I know what the result of the code is and it's correct in unit tests, but I'm not overly familiar with guava or how/why this implementation works. Also currently it doesn't appear to be safe if there is a null value in the list 'prices' either? So what I'm after:
- A general explanation of how the code works.
- Is it currently null safe? If not how can it made to be?