Skip to content

feature: #95 | Add composition, toUnchecked, identity, and ThrowingPredicate to throwing functional interfaces#112

Open
a-anand-91119 wants to merge 2 commits intoZeplinko:developfrom
a-anand-91119:main
Open

feature: #95 | Add composition, toUnchecked, identity, and ThrowingPredicate to throwing functional interfaces#112
a-anand-91119 wants to merge 2 commits intoZeplinko:developfrom
a-anand-91119:main

Conversation

@a-anand-91119
Copy link
Copy Markdown
Contributor

@a-anand-91119 a-anand-91119 commented Mar 28, 2026

Summary

Enhances all Throwing functional interfaces with composition support, JDK interop, and introduces a new ThrowingPredicate<T> interface.

Changes

ThrowingFunction<T, R>

  • andThen(ThrowingFunction) — compose two functions in sequence
  • compose(ThrowingFunction) — compose with a before-function
  • toUnchecked() — adapt to standard Function for use in streams
  • identity() — static factory returning an identity function

ThrowingBiFunction<T, U, R>

  • andThen(ThrowingFunction) — post-map the result
  • toUnchecked() — adapt to standard BiFunction

ThrowingConsumer<T> / ThrowingBiConsumer<T, U>

  • andThen(...) — chain two consumers in sequence
  • toUnchecked() — adapt to standard Consumer / BiConsumer

ThrowingRunnable / ThrowingSupplier<T>

  • toUnchecked() — adapt to standard Runnable / Supplier

New: ThrowingPredicate<T>

  • and, or, negate — boolean composition with short-circuit evaluation
  • isEqual(Object) — static null-safe equality predicate
  • not(ThrowingPredicate) — static negation factory (mirrors JDK 11 Predicate.not)
  • toUnchecked() — adapt to standard Predicate

Summary by CodeRabbit

  • New Features

    • Added composition methods to throwing functional interfaces for building function chains
    • Introduced toUnchecked() conversion method to adapt throwing functions to standard Java functional interfaces
    • Created new ThrowingPredicate interface with logical combinators (and, or, negate)
    • Added utility methods including identity() and isEqual()
  • Tests

    • Comprehensive test coverage for composition, conversion, and exception handling behaviors

…rowingPredicate to throwing functional interfaces
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 28, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 82f17062-cdec-4c80-9466-21a2cdd8525b

📥 Commits

Reviewing files that changed from the base of the PR and between 7959b57 and ac35bcd.

📒 Files selected for processing (14)
  • src/main/java/org/zeplinko/commons/lang/ext/util/function/ThrowingBiConsumer.java
  • src/main/java/org/zeplinko/commons/lang/ext/util/function/ThrowingBiFunction.java
  • src/main/java/org/zeplinko/commons/lang/ext/util/function/ThrowingConsumer.java
  • src/main/java/org/zeplinko/commons/lang/ext/util/function/ThrowingFunction.java
  • src/main/java/org/zeplinko/commons/lang/ext/util/function/ThrowingPredicate.java
  • src/main/java/org/zeplinko/commons/lang/ext/util/function/ThrowingRunnable.java
  • src/main/java/org/zeplinko/commons/lang/ext/util/function/ThrowingSupplier.java
  • src/test/java/org/zeplinko/commons/lang/ext/util/function/ThrowingBiConsumerTest.java
  • src/test/java/org/zeplinko/commons/lang/ext/util/function/ThrowingBiFunctionTest.java
  • src/test/java/org/zeplinko/commons/lang/ext/util/function/ThrowingConsumerTest.java
  • src/test/java/org/zeplinko/commons/lang/ext/util/function/ThrowingFunctionTest.java
  • src/test/java/org/zeplinko/commons/lang/ext/util/function/ThrowingPredicateTest.java
  • src/test/java/org/zeplinko/commons/lang/ext/util/function/ThrowingRunnableTest.java
  • src/test/java/org/zeplinko/commons/lang/ext/util/function/ThrowingSupplierTest.java

📝 Walkthrough

Walkthrough

Added composition and conversion utilities to Throwing* functional interfaces: andThen(), compose(), and(), or(), negate() methods enable chaining; toUnchecked() converts to standard Java functional types by wrapping checked exceptions; static helpers include identity(), isEqual(), not(). Comprehensive JUnit tests validate all behaviors.

Changes

Cohort / File(s) Summary
Throwing Consumer/Supplier/Runnable
src/main/java/org/zeplinko/commons/lang/ext/util/function/ThrowingConsumer.java, ThrowingRunnable.java, ThrowingSupplier.java
Added andThen() composition and toUnchecked() conversion to standard Java functional interfaces with checked-to-unchecked exception wrapping.
Throwing BiConsumer/BiFunction
src/main/java/org/zeplinko/commons/lang/ext/util/function/ThrowingBiConsumer.java, ThrowingBiFunction.java
Added andThen() composition and toUnchecked() conversion methods with null validation and exception propagation handling.
Throwing Function
src/main/java/org/zeplinko/commons/lang/ext/util/function/ThrowingFunction.java
Added andThen() and compose() for function chaining, static identity() factory, and toUnchecked() conversion with exception wrapping.
Throwing Predicate
src/main/java/org/zeplinko/commons/lang/ext/util/function/ThrowingPredicate.java
New interface with test/negate/and/or boolean composition methods, static isEqual() and not() helpers, and toUnchecked() conversion.
Comprehensive Test Coverage
src/test/java/org/zeplinko/commons/lang/ext/util/function/ThrowingBiConsumerTest.java, ThrowingBiFunctionTest.java, ThrowingConsumerTest.java, ThrowingFunctionTest.java, ThrowingPredicateTest.java, ThrowingRunnableTest.java, ThrowingSupplierTest.java
Extensive JUnit tests validating composition order, exception propagation/wrapping, null argument handling, and short-circuit evaluation behaviors across all new functional interface methods.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • ShivamNagpal
  • astha-singh-dev
  • zeplinko-bot

Poem

🐰 Hopping through exceptions with glee,
Composing consumers as they should be,
AndThen and toUnchecked align,
Throwing checked errors? Now they're mine!
Function by function, the chain grows long,
The rabbit refactors and nothing goes wrong! ✨🐇

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 26.32% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and comprehensively summarizes the main changes: adding composition, toUnchecked, identity, and ThrowingPredicate to throwing functional interfaces.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant