[
https://issues.apache.org/jira/browse/LANG-1733?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17845705#comment-17845705
]
Jongjin Bae edited comment on LANG-1733 at 5/12/24 3:23 PM:
------------------------------------------------------------
Thanks for your feedback.
I will implement this features in a new class in the function package.
the class name will be 'NullSafeOperations'.
was (Author: JIRAUSER305255):
Thanks for your feedback.
I will implement this features in a new class in the function package.
the class name will be 'NullSafeExecutor'.
> `null` handling feature in ObjectUtils
> --------------------------------------
>
> Key: LANG-1733
> URL: https://issues.apache.org/jira/browse/LANG-1733
> Project: Commons Lang
> Issue Type: New Feature
> Reporter: Jongjin Bae
> Priority: Major
>
> I have a new suggestion about null handling.
> I usually check a object is null or not before using it to avoid NPE.
> It is pretty obvious, but It is quite cumbersome and has some overhead.
> So I want to introduce the following null-safety methods in ObjectUtils class
> and make people easy to handle null without using if/else statement or
> Optional class, etc.
> {code:java}
> public static <T, R> R applyIfNotNull(final T object, final Function<T, R>
> function) {
> return object != null ? function.apply(object) : null;
> }
> public static <T> void acceptIfNotNull(final T object, final Consumer<T>
> consumer) {
> if (object != null) {
> consumer.accept(object);
> }
> }
> {code}
> What do you think about it?
> If it looks good, I will implement this feature.
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)