Request to add nonNullOrEmpty method to Strings class
See original GitHub issueI request to add the nonNullOrEmpty method to the String class. When use stream, can use method reference to write whether the string is null or empty.
stringStream.filter(Strings::nonNullOrEmpty) ...
I think this is useful. What do you think?
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
String.IsNullOrEmpty(String) Method (System) - Microsoft Learn
IsNullOrEmpty is a convenience method that enables you to simultaneously test whether a String is null or its value is String.Empty. It is...
Read more >Is extending String class with IsNullOrEmpty confusing?
IsNullOrEmpty (yourString) method. I was wondering if it's going to confuse developers or make code better if we extend String class to have...
Read more >C# | IsNullOrEmpty() Method - GeeksforGeeks
In C#, IsNullOrEmpty() is a string method. It is used to check whether the specified string is null or an Empty string. A...
Read more >String.IsNullOrEmpty() method with example in C#
String.IsNullOrEmpty() method is a built-in method of String class and it is used to check whether a string is Null or Empty? If...
Read more >Checking for Empty or Blank Strings in Java - Baeldung
Check out some simple ways in Java to test if a string is blank or ... Of course, it's pretty common to know...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Though we do have some methods (well,
Strings.isNullOrEmpty()
, at any rate) that do so, we generally don’t encourage methods that treatnull
and non-null
values the same. There are a lot of ways you could deal with this situation without us needing to add a new method:filter(not(Strings::isNullOrEmpty))
(Guava’sPredicates.not()
)filter((Strings::isNullOrEmpty).negate())
, but this probably doesn’t work without castingStrings::isNullOrEmpty
toPredicate<String>
map(Strings::emptyToNull).filter(Objects::notNull)
@cgdecker Thank you for presenting an example. I’ll use those.