You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by GitBox <gi...@apache.org> on 2022/02/14 22:45:29 UTC

[GitHub] [commons-codec] garydgregory commented on a change in pull request #78: Validate byte and string

garydgregory commented on a change in pull request #78:
URL: https://github.com/apache/commons-codec/pull/78#discussion_r806300692



##########
File path: src/main/java/org/apache/commons/codec/binary/StringUtils.java
##########
@@ -269,6 +269,25 @@ public static ByteBuffer getByteBufferUtf8(final String string) {
         return getBytes(string, StandardCharsets.UTF_8);
     }
 
+    /**
+     * <p>Checks if a CharSequence is empty ("") or null.</p>
+     *
+     * <pre>
+     * StringUtils.isEmpty(null)      = true
+     * StringUtils.isEmpty("")        = true
+     * StringUtils.isEmpty(" ")       = false
+     * StringUtils.isEmpty("bob")     = false
+     * StringUtils.isEmpty("  bob  ") = false
+     * </pre>
+     *
+     * @param cs  the CharSequence to check, may be null
+     * @return {@code true} if the CharSequence is empty or null
+     * @since 1.16
+     */
+    public static boolean isEmpty(final CharSequence cs) {

Review comment:
       Make this package-private and move it somewhere in the language package since it is the only place where it seems to be called, which will help as noted in my other comment.

##########
File path: src/main/java/org/apache/commons/codec/binary/BinaryCodec.java
##########
@@ -136,8 +136,10 @@
      * @param array
      *            the source array
      * @return {@code true} if the given array is {@code null} or empty (size 0.)
+     *
+     * @since 1.16 change visibility to public
      */
-    private static boolean isEmpty(final byte[] array) {
+    public static boolean isEmpty(final byte[] array) {

Review comment:
       Hello @arturobernalg 
   Please make this package private instead of public, this helps minimize the API footprint we will need to maintain for BC, especially since this is just for internal use.




-- 
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: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org