Skip to content

Functions and small improvements in Extractors

Compare
Choose a tag to compare
@ddimtirov ddimtirov released this 24 Jan 02:57
· 52 commits to master since this release
v0.2.0

The theme for v0.2.0 release is lambda utilities. This is not yet another Functional Java library, but rather adding small bits and pieces to help to the standard library to make it more debuggable and terse.

The Functions provides utilities that can be used with java.util.function objects and are especially convenient with lambdas. These include decorators adding human-readable toString(), convenient factories for functional objects intercepting arguments and return values, and a flexible fallback() combinator, trying multiple functions until the result matches a predicate and/or no exception is thrown.

The Groovy API got an extra closure.named('name') extension method for any Closure instance. As a byproduct, the DelegatedClosure is a convenient base class that one can extend when you want to write a decorator intercepting a method or two of a wrapped closure.

The Extractors now provides eachAccessible() as a way to enumerate and process every field, method or constructor of a class, including the privately inherited ones. It also allows you to throw exceptions, so no more catch (Exception e) arround reflection code. Another addition is linearized() providing a list of all supertypes for a class in a sensible order - superclasses first, then interfaces breadth-first and finally Object - comes handy when doing manual method dispatch (i.e. in some custom DI scenarios).

See also bintray version, javadocs at Sonatype or on javadocs.io (in case OSSRH is unavailable)