Skip to content

GROOVY-12031: Provide a DGM#takeIf method#2553

Merged
paulk-asert merged 1 commit into
apache:masterfrom
paulk-asert:groovy12031
May 25, 2026
Merged

GROOVY-12031: Provide a DGM#takeIf method#2553
paulk-asert merged 1 commit into
apache:masterfrom
paulk-asert:groovy12031

Conversation

@paulk-asert
Copy link
Copy Markdown
Contributor

No description provided.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.1855%. Comparing base (5318145) to head (af0f1b9).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@                Coverage Diff                 @@
##               master      #2553        +/-   ##
==================================================
+ Coverage     68.1844%   68.1855%   +0.0011%     
- Complexity      33086      33090         +4     
==================================================
  Files            1508       1508                
  Lines          126130     126131         +1     
  Branches        22878      22878                
==================================================
+ Hits            86001      86003         +2     
  Misses          32490      32490                
+ Partials         7639       7638         -1     
Files with missing lines Coverage Δ
.../codehaus/groovy/runtime/DefaultGroovyMethods.java 75.0982% <100.0000%> (+0.0070%) ⬆️

... and 10 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new Groovy GDK extension method takeIf (GROOVY-12031) to DefaultGroovyMethods, allowing values to be conditionally passed through fluent chains (returning the receiver or null), and updates inspector expectations accordingly.

Changes:

  • Introduces DefaultGroovyMethods#takeIf(T, Predicate) with GroovyDoc examples (inline groovyTestCase coverage).
  • Updates InspectorTest’s expected meta method name list to include takeIf.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java Adds the new takeIf GDK method and its GroovyDoc examples/tests.
src/test/groovy/groovy/inspect/InspectorTest.java Updates meta-method name expectations to account for the newly added DGM method.

Comment on lines +15094 to +15095
public static <T> T takeIf(T self, Predicate<T> condition) {
return condition.test(self) ? self : null;
@testlens-app
Copy link
Copy Markdown

testlens-app Bot commented May 22, 2026

✅ All tests passed ✅

⚠️ TestLens detected flakiness ⚠️

Test Summary

Check Project/Task Test Runs
Build and test / lts (21, ubuntu-latest) :groovy-groovysh:test HelpCommandTest > helpListsKnownCommands() ❌ ✅

🏷️ Commit: af0f1b9
▶️ Tests: 19920 executed
⚪️ Checks: 28/28 completed


Learn more about TestLens at testlens.app.

@paulk-asert paulk-asert merged commit cda6a7b into apache:master May 25, 2026
40 of 41 checks passed
@paulk-asert paulk-asert deleted the groovy12031 branch May 25, 2026 04:45
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.

3 participants