stratozero commented on PR #1455:
URL: https://github.com/apache/commons-lang/pull/1455#issuecomment-3365831341

   Thank you for pointing out `Consumers.apply` — I wasn’t aware of it.
   
   I agree that it provides the same functionality, but I would still like to 
make the case
   for having this method also exposed under `ObjectUtils`:
   
   - **Discoverability**: `ObjectUtils` is the natural place where developers 
look for
     null-handling helpers (`defaultIfNull`, `firstNonNull`, etc.).  
     Personally, I would not think of looking under `Consumers` for such a 
method.
   
   - **Usability**: `ObjectUtils` is frequently imported statically 
     (`import static ObjectUtils.*`), which makes methods like `ifNotNull` 
extremely concise
     and encourages adoption.
   
   - **API design**: the parameter order in `Consumers.apply` is reversed
     (lambda first, then the argument).  
     Having the object first (`ifNotNull(obj, consumer)`) reads more naturally 
and is more
     consistent with other `ObjectUtils` methods.
   
   Therefore, even if the underlying logic is a duplicate, placing this utility 
in
   `ObjectUtils` would simplify adoption and improve the intuitiveness of the 
API surface.
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to