Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
 
 
 
 
 
 
 
 

README.md

StreamUnthrower

Main thing - see class Unthrow.java

Lets you use checked exception in lambda expressions. One import and use!

import utils.stream.Unthrow;
...
    static class BlaBla {
        void method() throws IOException { ... }
        boolean isSomething() throws IOException { ... }
    }

    public void blablaDemo() {
        // :)
        getBlaBlaList().stream()
                .filter( blaBla -> Unthrow.wrap(() -> blaBla.isSomething()) )
                .forEach(blaBla -> Unthrow.wrapProc(() -> blaBla.method()) );
        // :(
        getBlaBlaList().stream()
                .filter( blaBla -> { try { return blaBla.isSomething(); } catch (Exception ex) { throw new RuntimeException(ex); } } )
                .forEach(blaBla -> { try { blaBla.method(); } catch (Exception ex) { throw new RuntimeException(ex); } } );
    }
...

Full Demo example of use.

Comparison examples of usage:

Features:

  • it does not create new exceptions - re use existing
  • a minimum code
  • no substitution Stream, only the wrapper over the lambda

License

MIT

Free Software, Hell Yeah!

About

Exception in lambda expressions

Resources

Packages

No packages published

Languages

You can’t perform that action at this time.