Giter Club home page Giter Club logo

unclutter-java's Introduction

Unclutter Java

Reduce cognitive load when parsing Java code by folding some verbose syntax.

Functional Interfaces

Reduces usages of functional interfaces (interfaces annotated with @FunctionalInterface) to what you would expect when you come from a language like Python.

Examples

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.

Creating instances

Removes visual noise from constructor calls.

Examples

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); // unfoldedFoo⋄(bar, baz);                       // folded

express-json

Folds (simple) express-json compositions into something that looks like JSON.

Examples

new Object(
    new Member("a", "b"),
    new Member("c", new Array(1, 2, 3))
); // unfolded

{
    "a": "b",
    "c": [1, 2, 3]
}; // folded

Logging

Folds log statements and consumers into a "comment". This reduces distraction and helps to focus on the actual functionality.

Examples

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);

Comparable.compareTo

Readable calls to compareTo

Examples

foo.compareTo(baz) < 0 // unfolded
foo < baz              // folded

License

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.

unclutter-java's People

Contributors

dmfs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

no3x

unclutter-java's Issues

Compatibility 2023.1

Can you please add 2023.1 compatibility to the plugin? The process should be straightforward, requiring the addition of new version number 231 and potentially including Java 17, without any alterations to the code. Can you please add a license to the repository as well?

Unclutter tests with confidence

At present a test with Confidence might look like

   Verifiable release_without_build = assertThat(new Release(1, 0, 0), is(release(1, 0, 0)));

by "folding" all parenthesis of methods that return Qualitys or Verifiables to it would look like

   Verifiable release_without_build = assertThat new Release(1, 0, 0), is release 1, 0, 0   ;

or, if we only fold qualities that delegate to other qualities:

   Verifiable release_without_build = assertThat new Release(1, 0, 0), is release(1, 0, 0)  ;

Alternatively it might be a good idea to fold only opening parenthesis to and fold closing parenthesis to `` to get

   Verifiable release_without_build = assertThat new Release(1, 0, 0), is release(1, 0, 0);

This certainly needs to be checked with more complex test cases.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.