feature: #95 | Implement Throwing Functional Lambdas#97
feature: #95 | Implement Throwing Functional Lambdas#97a-anand-91119 merged 1 commit intodevelopfrom
Conversation
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughThese changes introduce 6 new functional interfaces in the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~15 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (12)
🔇 Additional comments (12)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
11d78d8 to
153f086
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR implements throwing functional lambdas by introducing six new functional interfaces that allow checked exceptions to be thrown, mirroring Java's standard functional interfaces but with exception-handling capabilities.
- Adds six new throwing functional interfaces:
ThrowingSupplier,ThrowingRunnable,ThrowingFunction,ThrowingConsumer,ThrowingBiFunction, andThrowingBiConsumer - Each interface includes comprehensive Javadoc documentation with usage context
- Comprehensive test coverage for all interfaces with multiple test scenarios per interface
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| ThrowingSupplier.java | Defines a Supplier-like interface that allows get() to throw checked exceptions |
| ThrowingRunnable.java | Defines a Runnable-like interface that allows run() to throw checked exceptions |
| ThrowingFunction.java | Defines a Function-like interface that allows apply() to throw checked exceptions |
| ThrowingConsumer.java | Defines a Consumer-like interface that allows accept() to throw checked exceptions |
| ThrowingBiFunction.java | Defines a BiFunction-like interface that allows apply() to throw checked exceptions |
| ThrowingBiConsumer.java | Defines a BiConsumer-like interface that allows accept() to throw checked exceptions |
| ThrowingSupplierTest.java | Comprehensive tests for ThrowingSupplier including exception propagation scenarios |
| ThrowingRunnableTest.java | Comprehensive tests for ThrowingRunnable including side effects and exception handling |
| ThrowingFunctionTest.java | Comprehensive tests for ThrowingFunction with various transformation scenarios |
| ThrowingConsumerTest.java | Comprehensive tests for ThrowingConsumer with multiple consumption scenarios |
| ThrowingBiFunctionTest.java | Comprehensive tests for ThrowingBiFunction with null handling and exception propagation |
| ThrowingBiConsumerTest.java | Comprehensive tests for ThrowingBiConsumer with map operations and null value handling |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
153f086 to
0f211b1
Compare
0f211b1 to
0042a02
Compare
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 12 out of 12 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@ShivamNagpal We can use the throwing supplier to support try with resources. something like Try.withResource(
ThrowingSupplier<R1> resourceSupplier,
ThrowingFunction<T> tryBlockContent
); |
This pull request introduces a suite of custom functional interfaces that mirror the standard Java functional interfaces, but allow their methods to throw checked exceptions. Additionally, comprehensive unit tests are provided for each new interface to ensure correct behavior and exception handling. These changes make it easier to use lambdas and method references that throw checked exceptions in functional programming contexts.
New functional interfaces supporting checked exceptions
ThrowingConsumer,ThrowingBiConsumer,ThrowingFunction,ThrowingBiFunction,ThrowingSupplier, andThrowingRunnableinterfaces insrc/main/java/org/zeplinko/commons/lang/ext/util/function/, each allowing their main method to throw a checkedException. [1] [2] [3] [4] [5] [6]Unit tests for new interfaces
src/test/java/org/zeplinko/commons/lang/ext/util/function/, verifying normal operation, null handling, exception propagation, repeated invocation, and handling of complex objects. [1] [2] [3] [4] [5] [6]Summary by CodeRabbit
Release Notes
New Features
Tests