This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Map<Color, Long> map = | |
people.stream().collect(Collectors.groupingBy( | |
Person::getFavoriteColor, | |
Collectors.counting())); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Map<Color, List<Person>> map = people | |
.stream() | |
.collect(Collectors.groupingBy(Person::getFavoriteColor)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Map<Color, Set<Person>> map = | |
people.stream().collect(Collectors.groupingBy( | |
Person::getFavoriteColor, | |
Collectors.toSet())); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MutableSetMultimap<Color, Person> multimap = | |
people.groupBy(Person::getFavoriteColor); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MutableSet<Address> addresses = people.collect(Person::getAddress); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MutableSet<Person> people = ...; | |
MutableSet<Address> addresses = people | |
.asLazy() | |
.collect(Person::getAddress) | |
.toSet(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Set<Person> people = ...; | |
Set<Address> addresses = people | |
.stream() | |
.map(Person::getAddress) | |
.collect(Collectors.toSet()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public Option<V> get(Object key) | |
{ | |
V result = this.table.get(key); | |
if (result == null && !this.table.containsKey(key)) | |
{ | |
return None.INSTANCE; | |
} | |
return new Some<V>(result); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public enum None implements Option<Nothing> | |
{ | |
INSTANCE; | |
public Nothing get() | |
{ | |
throw new UnsupportedOperationException("None.get()"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
undefined :: a | |
error :: [Char] -> a |