Added method to convert Object to String that support null values.#889
Closed
EACUAMBA wants to merge 4 commits intoapache:masterfrom
EACUAMBA:master
Closed
Added method to convert Object to String that support null values.#889EACUAMBA wants to merge 4 commits intoapache:masterfrom EACUAMBA:master
EACUAMBA wants to merge 4 commits intoapache:masterfrom
EACUAMBA:master
Conversation
… default or default value given.
… default or default value given.
kinow
requested changes
May 1, 2022
| if(object == null) | ||
| return defaultString(nullDefault); | ||
|
|
||
| return Objects.toString(object); |
Member
There was a problem hiding this comment.
Hi @EACUAMBA ,
I think instead of this new method, users could just use the Java 8+ Objects.toString(Object o, String nullDefault) - https://docs.oracle.com/javase/8/docs/api/java/util/Objects.html#toString-java.lang.Object-java.lang.String-
Author
There was a problem hiding this comment.
Hi @kinow,
You are right, the toString method in Objects can work too. Thanks.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I added a method to help people convert any object to String or return an empty String.
I added this methods because I was facing a problem with convert Wrap classes like Integer, Double to String.
I needed something to return empty string or a default value.
This is my contribute.