Reduce cognitive load when parsing Java code by folding some verbose syntax.
Reduces usages of functional interfaces (interfaces annotated with @FunctionalInterface
) to what you would
expect when you come
from a language like Python.
Function<Baz,Buzz> f=foo::bar;
f.apply(baz); // unfolded
f(baz); // folded
Predicate<String> isBlank=String::isBlank;
if(isBlank.test("not blank")) { … } // unfolded
if(isBlank("not blank")) { … } // folded
Note, only the sole non-default
and non-static
method of a functional interface is folded.
Removes visual noise from constructor calls.
new Foo(bar, baz); // unfolded
Foo(bar, baz); // folded
new Foo<>(bar, baz); // unfolded
Foo⋄(bar, baz); // folded
new com.example.Foo<String>(bar, baz); // unfolded
…Foo⋄(bar, baz); // folded
Folds (simple) express-json compositions into something that looks like JSON.
new Object(
new Member("a", "b"),
new Member("c", new Array(1, 2, 3))
); // unfolded
{
"a": "b",
"c": [1, 2, 3]
}; // folded
Folds log statements and consumers into a "comment". This reduces distraction and helps to focus on the actual functionality.
log.trace("some trace log"); // unfolded
/*log*/ // folded
rxflowable
.map(mapFunction)
.doOnNext(value -> log.trace("next value was {}", value)) // unfolded
.subscribe(subscriber);
rxflowable
.map(mapFunction)
.doOnNext(/*log*/) // folded
.subscribe(subscriber);
Readable calls to compareTo
foo.compareTo(baz) < 0 // unfolded
foo < baz // folded
Copyright 2023 dmfs GmbH
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an " AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.