New java.util.Strings class
Alberto Otero Rodríguez
albest512 at hotmail.com
Mon May 17 12:58:24 UTC 2021
Hi, members of the core-libs developers of OpenJDK.
I think Java needs a Strings class similar to the java.util.Objects class of Java 16 to be used in method arguments, return types and Stream filters.
I have coded it myself here based on the Objects implementation of Java 16 (please have a look):
https://github.com/Aliuken/Java-Strings/blob/main/Strings.java
In fact, I think it would be useful also adding annotations for method arguments and return types such as:
- @NonNull
- @NonNullElse(defaultValue)
- @NonNullElseGet(class::supplierMethod)
- @NonNullNorEmpty
- @NonNullNorEmptyElse(defaultValue)
- @NonNullNorEmptyElseGet(class::supplierMethod)
With that kind of annotations, you could assume thinks like:
- an argument or return type cannot have value null, but an Exception
- an argument or return type cannot have value null, but a default value
What do you think?
Waiting for your response.
PS: I am sending this email repeated. I have sended it yesterday with my other email account (alber84ou at gmail.com), but I wasn't a member of this mailing list. Now I have become a member with this other email account.
Regards,
Alberto Otero Rodríguez.
More information about the core-libs-dev
mailing list