Skip to content

Latest commit

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

java-anonymous-types

Example of how to create anonymous types in java, using intersection casts

with((Anon & Quacks & Waddles) i -> i, ducklike -> {
ducklike.quack();
ducklike.waddle();
});

You can also enhance existing types with List with new methods like map

interfaceMappable<T> extendsDelegatesTo<List<T>> {
default <R> List<R> map(Function<T,R> mapper) {
returndelegate().stream().map(mapper).collect(Collectors.toList());
}
}
with((ForwardingList<String> & Mappable<String>)() -> stringList, list -> {
list.map(String::toUpperCase).forEach(System.out::println);
});

About

Anonymous types in java

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages