Using new Optics support in #higher-kinded-j is easy, just add a simple annotation to automatically generate Lenses, Prisms, and Isomorphisms then compose lenses for incredibly readable, deep updates:
// Create a "shortcut" lens by composing others
var userToStreetName = UserLenses.address()
.andThen(AddressLenses.street())
.andThen(StreetLenses.name());
// Perform the deep update in a single line
User updatedUser = userToStreetName.set("New Street", user);
You can perform effectful operations (failable, async, stateful). The library is also fully extensible, allowing you to define custom Traversal instances for any data structure.
Check out the docs, with loads of examples to get you started!
https://higher-kinded-j.github.io/
#Java #FunctionalProgramming #JavaDev #FP #Optics #HigherKindedTypes