== groupingBy and downstream collectors == byCountry : {IN=[Order[customer=ankur, product=laptop, amount=1200.0, country=IN], Order[customer=ankur, product=tablet, amount=400.0, country=IN]], US=[Order[customer=alex, product=phone, amount=800.0, country=US], Order[customer=brian, product=laptop, amount=1500.0, country=US]]} countByCustomer : {ankur=2, alex=1, brian=1} revenueByCountry : {IN=1600.0, US=2300.0} productsByCountry : {IN=[laptop, tablet], US=[phone, laptop]} topByCountry : {IN=Optional[Order[customer=ankur, product=laptop, amount=1200.0, country=IN]], US=Optional[Order[customer=brian, product=laptop, amount=1500.0, country=US]]} sorted keys (TreeMap): {IN=2, US=2} == partitioningBy == amount > 1000 : {false=2, true=2} amount > 5000 : {false=4, true=0} <- both keys present even when one side is empty groupingBy > 5000 : {false=4} <- only the keys that occurred == joining, toMap, collectingAndThen == customerCsv : [ankur, alex, brian] toMap w/ merge : {ankur=1600.0, alex=800.0, brian=1500.0} toMap w/o merge : IllegalStateException: Duplicate key ankur (attempted merging values 1200.0 and 400.0) toMap null value : NullPointerException unmodifiable names : [ankur, alex, brian] == Java 9-12 additions == filtering (> 1300) : {IN=0, US=1} filter then group : {US=1} <- IN disappears: filter removes the element before grouping sees it flatMapping : {IN=[l, t], US=[p, l]} summarizingDouble : DoubleSummaryStatistics{count=4, sum=3900.000000, min=400.000000, average=975.000000, max=1500.000000} teeing (min,max) : MinMax[min=Order[customer=ankur, product=tablet, amount=400.0, country=IN], max=Order[customer=brian, product=laptop, amount=1500.0, country=US]] teeing (avg) : 975.0