3
Was ist die Java Stream-API-Alternative zur LambdaJ-Indexierung? Nehmen wir an, ich habe Code wie diesenJava-Stream-Alternative zu LambdaJ-Index
List<Product> products = ...
Map<Month, Product> productsOnMonths = Lambda.index(products, Lambda.on(Product.class).getMonth());
Wo ich weiß, dass jedes Produkt einzigartige Monat Attribut hat.
Sehr elegant. Schließlich habe ich eine Version mit Identity-Funktion verwendet. 'products.stream(). collect (Collectors.toMap (Produkt :: getMonth, Function.identity()));' – Behnil