-
Notifications
You must be signed in to change notification settings - Fork 244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a method to conditionally apply a Consumer on a nullable input #1419
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1419 +/- ##
===============================================
+ Coverage 68.127% 68.445% +0.318%
- Complexity 8381 8673 +292
===============================================
Files 573 573
Lines 33985 34873 +888
Branches 5668 5930 +262
===============================================
+ Hits 23153 23869 +716
- Misses 8643 8783 +140
- Partials 2189 2221 +32
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yfarjoun This seems like a reasonable method to add. Two comments and then 👍
} | ||
|
||
public static <T> void applyIfNotNull(final T input, Consumer<T> action) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
javadoc
@@ -114,6 +114,10 @@ public void testFileReadingAndWriting() throws IOException { | |||
String randomizedTestString = TEST_STRING + System.currentTimeMillis(); | |||
for (String ext : TEST_FILE_EXTENSIONS) { | |||
File f = File.createTempFile(TEST_FILE_PREFIX, ext); | |||
IOUtil.assertFileIsReadable(f); | |||
|
|||
CodeUtil.applyIfNotNull(f,IOUtil::assertFileIsReadable); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a strange test for this method... Why not give it its own test case in a new CodeUtilUnitTest class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Description
Please explain the changes you made here.
Explain the motivation for making this change. What existing problem does the pull request solve?
Things to think about before submitting: