You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2025/09/03 12:30:45 UTC

(commons-lang) branch master updated (22d2664b6 -> 8a5ea521f)

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-lang.git


    from 22d2664b6 Fix CalendarUtils.toLocalDate() Javadoc return type description #1440
     new ae8ba316c Revert to the released behavior and update tests
     new b284082bf Comments
     new 719acc849 Javadoc
     new 9456a9a31 Improve Javadocs for Conversion
     new 42fef8bdb Better Javadoc and exception messages
     new 8a5ea521f Use JRE constants

The 6 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/changes/changes.xml                            |    2 +-
 .../java/org/apache/commons/lang3/Conversion.java  | 1060 +++++++++-----------
 .../org/apache/commons/lang3/ConversionTest.java   |   86 +-
 3 files changed, 507 insertions(+), 641 deletions(-)


(commons-lang) 03/06: Javadoc

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-lang.git

commit 719acc8494ad9f023e533e559b326e044cb4b480
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Wed Sep 3 08:01:14 2025 -0400

    Javadoc
---
 .../java/org/apache/commons/lang3/Conversion.java  | 835 +++++++++------------
 1 file changed, 370 insertions(+), 465 deletions(-)

diff --git a/src/main/java/org/apache/commons/lang3/Conversion.java b/src/main/java/org/apache/commons/lang3/Conversion.java
index aff2e7a19..3ccc8c7ba 100644
--- a/src/main/java/org/apache/commons/lang3/Conversion.java
+++ b/src/main/java/org/apache/commons/lang3/Conversion.java
@@ -14,6 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package org.apache.commons.lang3;
 
 import java.util.UUID;
@@ -34,81 +35,73 @@
  * <li>int or intArray</li>
  * <li>long or longArray</li>
  * <li>hex: a String containing hexadecimal digits (lowercase in destination)</li>
- * <li>hexDigit: a Char containing a hexadecimal digit (lowercase in destination)</li>
+ * <li>hexDigit: a char containing a hexadecimal digit (lowercase in destination)</li>
  * <li>uuid</li>
  * </ul>
  * <p>
- * Endianness field: little-endian is the default, in this case the field is absent. In case of
- * big-endian, the field is "Be".<br> Bit ordering: Lsb0 is the default, in this case the field
- * is absent. In case of Msb0, the field is "Msb0".
+ * Endianness field: little-endian is the default, in this case the field is absent. In case of big-endian, the field is "Be".<br>
+ * Bit ordering: Lsb0 is the default, in this case the field is absent. In case of Msb0, the field is "Msb0".
  * </p>
  * <p>
- * Example: intBeMsb0ToHex convert an int with big-endian byte order and Msb0 bit order into its
- * hexadecimal string representation
+ * Example: intBeMsb0ToHex convert an int with big-endian byte order and Msb0 bit order into its hexadecimal string representation
  * </p>
  * <p>
- * Most of the methods provide only default encoding for destination, this limits the number of
- * ways to do one thing. Unless you are dealing with data from/to outside of the JVM platform,
- * you should not need to use "Be" and "Msb0" methods.
+ * Most of the methods provide only default encoding for destination, this limits the number of ways to do one thing. Unless you are dealing with data from/to
+ * outside of the JVM platform, you should not need to use "Be" and "Msb0" methods.
  * </p>
  * <p>
- * Development status: work on going, only a part of the little-endian, Lsb0 methods implemented
- * so far.
+ * Development status: work on going, only a part of the little-endian, Lsb0 methods implemented so far.
  * </p>
  *
  * @since 3.2
  */
 public class Conversion {
 
-    private static final boolean[] TTTT = {true, true, true, true};
-    private static final boolean[] FTTT = {false, true, true, true};
-    private static final boolean[] TFTT = {true, false, true, true};
-    private static final boolean[] FFTT = {false, false, true, true};
-    private static final boolean[] TTFT = {true, true, false, true};
-    private static final boolean[] FTFT = {false, true, false, true};
-    private static final boolean[] TFFT = {true, false, false, true};
-    private static final boolean[] FFFT = {false, false, false, true};
-    private static final boolean[] TTTF = {true, true, true, false};
-    private static final boolean[] FTTF = {false, true, true, false};
-    private static final boolean[] TFTF = {true, false, true, false};
-    private static final boolean[] FFTF = {false, false, true, false};
-    private static final boolean[] TTFF = {true, true, false, false};
-    private static final boolean[] FTFF = {false, true, false, false};
-    private static final boolean[] TFFF = {true, false, false, false};
-    private static final boolean[] FFFF = {false, false, false, false};
+    private static final boolean[] TTTT = { true, true, true, true };
+    private static final boolean[] FTTT = { false, true, true, true };
+    private static final boolean[] TFTT = { true, false, true, true };
+    private static final boolean[] FFTT = { false, false, true, true };
+    private static final boolean[] TTFT = { true, true, false, true };
+    private static final boolean[] FTFT = { false, true, false, true };
+    private static final boolean[] TFFT = { true, false, false, true };
+    private static final boolean[] FFFT = { false, false, false, true };
+    private static final boolean[] TTTF = { true, true, true, false };
+    private static final boolean[] FTTF = { false, true, true, false };
+    private static final boolean[] TFTF = { true, false, true, false };
+    private static final boolean[] FFTF = { false, false, true, false };
+    private static final boolean[] TTFF = { true, true, false, false };
+    private static final boolean[] FTFF = { false, true, false, false };
+    private static final boolean[] TFFF = { true, false, false, false };
+    private static final boolean[] FFFF = { false, false, false, false };
 
     /**
-     * Converts the first 4 bits of a binary (represented as boolean array) in big-endian Msb0
-     * bit ordering to a hexadecimal digit.
+     * Converts the first 4 bits of a binary (represented as boolean array) in big-endian Msb0 bit ordering to a hexadecimal digit.
      *
      * <p>
-     * (1, 0, 0, 0) is converted as follow: '8' (1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0) is converted
-     * to '4'.
+     * (1, 0, 0, 0) is converted as follow: '8' (1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0) is converted to '4'.
      * </p>
      *
      * @param src the binary to convert.
      * @return a hexadecimal digit representing the selected bits.
      * @throws IllegalArgumentException if {@code src} is empty.
-     * @throws NullPointerException if {@code src} is {@code null}.
+     * @throws NullPointerException     if {@code src} is {@code null}.
      */
     public static char binaryBeMsb0ToHexDigit(final boolean[] src) {
         return binaryBeMsb0ToHexDigit(src, 0);
     }
 
     /**
-     * Converts a binary (represented as boolean array) in big-endian Msb0 bit ordering to a
-     * hexadecimal digit.
+     * Converts a binary (represented as boolean array) in big-endian Msb0 bit ordering to a hexadecimal digit.
      *
      * <p>
-     * (1, 0, 0, 0) with srcPos = 0 is converted as follow: '8' (1, 0, 0, 0, 0, 0, 0, 0,
-     * 0, 0, 0, 1, 0, 1, 0, 0) with srcPos = 2 is converted to '5'.
+     * (1, 0, 0, 0) with srcPos = 0 is converted as follow: '8' (1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0) with srcPos = 2 is converted to '5'.
      * </p>
      *
-     * @param src the binary to convert.
+     * @param src    the binary to convert.
      * @param srcPos the position of the LSB to start the conversion.
      * @return a hexadecimal digit representing the selected bits.
-     * @throws IllegalArgumentException if {@code src} is empty.
-     * @throws NullPointerException if {@code src} is {@code null}.
+     * @throws IllegalArgumentException  if {@code src} is empty.
+     * @throws NullPointerException      if {@code src} is {@code null}.
      * @throws IndexOutOfBoundsException if {@code srcPos} is outside the array.
      */
     public static char binaryBeMsb0ToHexDigit(final boolean[] src, final int srcPos) {
@@ -147,7 +140,7 @@ public static char binaryBeMsb0ToHexDigit(final boolean[] src, final int srcPos)
     }
 
     /**
-     * Converts binary (represented as boolean array) into a byte using the default (little endian, Lsb0) byte and bit ordering.
+     * Converts binary (represented as boolean array) into a byte using the default (little-endian, Lsb0) byte and bit ordering.
      *
      * @param src     the binary to convert.
      * @param srcPos  the position in {@code src}, in boolean unit, from where to start the conversion.
@@ -159,8 +152,7 @@ public static char binaryBeMsb0ToHexDigit(final boolean[] src, final int srcPos)
      * @throws IllegalArgumentException       if {@code nBools-1+dstPos >= 8}.
      * @throws ArrayIndexOutOfBoundsException if {@code srcPos + nBools > src.length}.
      */
-    public static byte binaryToByte(final boolean[] src, final int srcPos, final byte dstInit, final int dstPos,
-            final int nBools) {
+    public static byte binaryToByte(final boolean[] src, final int srcPos, final byte dstInit, final int dstPos, final int nBools) {
         if (src.length == 0 && srcPos == 0 || 0 == nBools) {
             return dstInit;
         }
@@ -178,35 +170,33 @@ public static byte binaryToByte(final boolean[] src, final int srcPos, final byt
     }
 
     /**
-     * Converts binary (represented as boolean array) to a hexadecimal digit using the default
-     * (Lsb0) bit ordering.
+     * Converts binary (represented as boolean array) to a hexadecimal digit using the default (Lsb0) bit ordering.
      *
      * <p>
-     * (1, 0, 0, 0) is converted as follow: '1'
+     * (1, 0, 0, 0) is converted as follow: '1'.
      * </p>
      *
-     * @param src the binary to convert
-     * @return a hexadecimal digit representing the selected bits
-     * @throws IllegalArgumentException if {@code src} is empty
-     * @throws NullPointerException if {@code src} is {@code null}
+     * @param src the binary to convert.
+     * @return a hexadecimal digit representing the selected bits.
+     * @throws IllegalArgumentException if {@code src} is empty.
+     * @throws NullPointerException     if {@code src} is {@code null}.
      */
     public static char binaryToHexDigit(final boolean[] src) {
         return binaryToHexDigit(src, 0);
     }
 
     /**
-     * Converts binary (represented as boolean array) to a hexadecimal digit using the default
-     * (Lsb0) bit ordering.
+     * Converts binary (represented as boolean array) to a hexadecimal digit using the default (Lsb0) bit ordering.
      *
      * <p>
-     * (1, 0, 0, 0) is converted as follow: '1'
+     * (1, 0, 0, 0) is converted as follow: '1'.
      * </p>
      *
-     * @param src the binary to convert
-     * @param srcPos the position of the LSB to start the conversion
-     * @return a hexadecimal digit representing the selected bits
-     * @throws IllegalArgumentException if {@code src} is empty
-     * @throws NullPointerException if {@code src} is {@code null}
+     * @param src    the binary to convert.
+     * @param srcPos the position of the LSB to start the conversion.
+     * @return a hexadecimal digit representing the selected bits.
+     * @throws IllegalArgumentException if {@code src} is empty.
+     * @throws NullPointerException     if {@code src} is {@code null}.
      */
     public static char binaryToHexDigit(final boolean[] src, final int srcPos) {
         if (src.length == 0) {
@@ -237,38 +227,33 @@ public static char binaryToHexDigit(final boolean[] src, final int srcPos) {
     }
 
     /**
-     * Converts binary (represented as boolean array) to a hexadecimal digit using the Msb0 bit
-     * ordering.
+     * Converts binary (represented as boolean array) to a hexadecimal digit using the Msb0 bit ordering.
      *
      * <p>
-     * (1, 0, 0, 0) is converted as follow: '8'
+     * (1, 0, 0, 0) is converted as follow: '8'.
      * </p>
      *
-     * @param src the binary to convert
-     * @return a hexadecimal digit representing the selected bits
-     * @throws IllegalArgumentException if {@code src} is empty, {@code src.length < 4} or
-     *             {@code src.length > 8}
-     * @throws NullPointerException if {@code src} is {@code null}
+     * @param src the binary to convert.
+     * @return a hexadecimal digit representing the selected bits.
+     * @throws IllegalArgumentException if {@code src} is empty, {@code src.length < 4} or {@code src.length > 8}.
+     * @throws NullPointerException     if {@code src} is {@code null}.
      */
     public static char binaryToHexDigitMsb0_4bits(final boolean[] src) {
         return binaryToHexDigitMsb0_4bits(src, 0);
     }
 
     /**
-     * Converts binary (represented as boolean array) to a hexadecimal digit using the Msb0 bit
-     * ordering.
+     * Converts binary (represented as boolean array) to a hexadecimal digit using the Msb0 bit ordering.
      *
      * <p>
-     * (1, 0, 0, 0) is converted as follow: '8' (1, 0, 0, 1, 1, 0, 1, 0) with srcPos = 3 is converted
-     * to 'D'
+     * (1, 0, 0, 0) is converted as follow: '8' (1, 0, 0, 1, 1, 0, 1, 0) with srcPos = 3 is converted to 'D'
      * </p>
      *
-     * @param src the binary to convert
-     * @param srcPos the position of the LSB to start the conversion
-     * @return a hexadecimal digit representing the selected bits
-     * @throws IllegalArgumentException if {@code src} is empty, {@code src.length > 8} or
-     *             {@code src.length - srcPos < 4}
-     * @throws NullPointerException if {@code src} is {@code null}
+     * @param src    the binary to convert.
+     * @param srcPos the position of the LSB to start the conversion.
+     * @return a hexadecimal digit representing the selected bits.
+     * @throws IllegalArgumentException if {@code src} is empty, {@code src.length > 8} or {@code src.length - srcPos < 4}.
+     * @throws NullPointerException     if {@code src} is {@code null}.
      */
     public static char binaryToHexDigitMsb0_4bits(final boolean[] src, final int srcPos) {
         if (src.length > 8) {
@@ -302,22 +287,19 @@ public static char binaryToHexDigitMsb0_4bits(final boolean[] src, final int src
     }
 
     /**
-     * Converts binary (represented as boolean array) into an int using the default (little
-     * endian, Lsb0) byte and bit ordering.
+     * Converts binary (represented as boolean array) into an int using the default (little endian, Lsb0) byte and bit ordering.
      *
-     * @param src the binary to convert
-     * @param srcPos the position in {@code src}, in boolean unit, from where to start the
-     *            conversion
-     * @param dstInit initial value of the destination int
-     * @param dstPos the position of the LSB, in bits, in the result int
-     * @param nBools the number of booleans to convert
-     * @return an int containing the selected bits
-     * @throws NullPointerException if {@code src} is {@code null}
-     * @throws IllegalArgumentException if {@code nBools-1+dstPos >= 32}
-     * @throws ArrayIndexOutOfBoundsException if {@code srcPos + nBools > src.length}
+     * @param src     the binary to convert.
+     * @param srcPos  the position in {@code src}, in boolean unit, from where to start the conversion.
+     * @param dstInit initial value of the destination int.
+     * @param dstPos  the position of the LSB, in bits, in the result int.
+     * @param nBools  the number of booleans to convert.
+     * @return an int containing the selected bits.
+     * @throws NullPointerException           if {@code src} is {@code null}.
+     * @throws IllegalArgumentException       if {@code nBools-1+dstPos >= 32}.
+     * @throws ArrayIndexOutOfBoundsException if {@code srcPos + nBools > src.length}.
      */
-    public static int binaryToInt(final boolean[] src, final int srcPos, final int dstInit, final int dstPos,
-            final int nBools) {
+    public static int binaryToInt(final boolean[] src, final int srcPos, final int dstInit, final int dstPos, final int nBools) {
         if (src.length == 0 && srcPos == 0 || 0 == nBools) {
             return dstInit;
         }
@@ -335,22 +317,19 @@ public static int binaryToInt(final boolean[] src, final int srcPos, final int d
     }
 
     /**
-     * Converts binary (represented as boolean array) into a long using the default (little
-     * endian, Lsb0) byte and bit ordering.
+     * Converts binary (represented as boolean array) into a long using the default (little endian, Lsb0) byte and bit ordering.
      *
-     * @param src the binary to convert
-     * @param srcPos the position in {@code src}, in boolean unit, from where to start the
-     *            conversion
-     * @param dstInit initial value of the destination long
-     * @param dstPos the position of the LSB, in bits, in the result long
-     * @param nBools the number of booleans to convert
-     * @return a long containing the selected bits
-     * @throws NullPointerException if {@code src} is {@code null}
-     * @throws IllegalArgumentException if {@code nBools-1+dstPos >= 64}
-     * @throws ArrayIndexOutOfBoundsException if {@code srcPos + nBools > src.length}
+     * @param src     the binary to convert.
+     * @param srcPos  the position in {@code src}, in boolean unit, from where to start the conversion.
+     * @param dstInit initial value of the destination long.
+     * @param dstPos  the position of the LSB, in bits, in the result long.
+     * @param nBools  the number of booleans to convert.
+     * @return a long containing the selected bits.
+     * @throws NullPointerException           if {@code src} is {@code null}.
+     * @throws IllegalArgumentException       if {@code nBools-1+dstPos >= 64}.
+     * @throws ArrayIndexOutOfBoundsException if {@code srcPos + nBools > src.length}.
      */
-    public static long binaryToLong(final boolean[] src, final int srcPos, final long dstInit, final int dstPos,
-            final int nBools) {
+    public static long binaryToLong(final boolean[] src, final int srcPos, final long dstInit, final int dstPos, final int nBools) {
         if (src.length == 0 && srcPos == 0 || 0 == nBools) {
             return dstInit;
         }
@@ -368,22 +347,19 @@ public static long binaryToLong(final boolean[] src, final int srcPos, final lon
     }
 
     /**
-     * Converts binary (represented as boolean array) into a short using the default (little
-     * endian, Lsb0) byte and bit ordering.
+     * Converts binary (represented as boolean array) into a short using the default (little endian, Lsb0) byte and bit ordering.
      *
-     * @param src the binary to convert
-     * @param srcPos the position in {@code src}, in boolean unit, from where to start the
-     *            conversion
-     * @param dstInit initial value of the destination short
-     * @param dstPos the position of the LSB, in bits, in the result short
-     * @param nBools the number of booleans to convert
-     * @return a short containing the selected bits
-     * @throws NullPointerException if {@code src} is {@code null}
-     * @throws IllegalArgumentException if {@code nBools-1+dstPos >= 16}
-     * @throws ArrayIndexOutOfBoundsException if {@code srcPos + nBools > src.length}
+     * @param src     the binary to convert.
+     * @param srcPos  the position in {@code src}, in boolean unit, from where to start the conversion.
+     * @param dstInit initial value of the destination short.
+     * @param dstPos  the position of the LSB, in bits, in the result short.
+     * @param nBools  the number of booleans to convert.
+     * @return a short containing the selected bits.
+     * @throws NullPointerException           if {@code src} is {@code null}.
+     * @throws IllegalArgumentException       if {@code nBools-1+dstPos >= 16}.
+     * @throws ArrayIndexOutOfBoundsException if {@code srcPos + nBools > src.length}.
      */
-    public static short binaryToShort(final boolean[] src, final int srcPos, final short dstInit, final int dstPos,
-            final int nBools) {
+    public static short binaryToShort(final boolean[] src, final int srcPos, final short dstInit, final int dstPos, final int nBools) {
         if (src.length == 0 && srcPos == 0 || 0 == nBools) {
             return dstInit;
         }
@@ -401,22 +377,19 @@ public static short binaryToShort(final boolean[] src, final int srcPos, final s
     }
 
     /**
-     * Converts an array of byte into an int using the default (little-endian, Lsb0) byte and bit
-     * ordering.
+     * Converts an array of byte into an int using the default (little-endian, Lsb0) byte and bit ordering.
      *
-     * @param src the byte array to convert
-     * @param srcPos the position in {@code src}, in byte unit, from where to start the
-     *            conversion
-     * @param dstInit initial value of the destination int
-     * @param dstPos the position of the LSB, in bits, in the result int
-     * @param nBytes the number of bytes to convert
-     * @return an int containing the selected bits
-     * @throws NullPointerException if {@code src} is {@code null}
-     * @throws IllegalArgumentException if {@code (nBytes-1)*8+dstPos >= 32}
-     * @throws ArrayIndexOutOfBoundsException if {@code srcPos + nBytes > src.length}
+     * @param src     the byte array to convert.
+     * @param srcPos  the position in {@code src}, in byte unit, from where to start the conversion.
+     * @param dstInit initial value of the destination int.
+     * @param dstPos  the position of the LSB, in bits, in the result int.
+     * @param nBytes  the number of bytes to convert.
+     * @return an int containing the selected bits.
+     * @throws NullPointerException           if {@code src} is {@code null}.
+     * @throws IllegalArgumentException       if {@code (nBytes-1)*8+dstPos >= 32}.
+     * @throws ArrayIndexOutOfBoundsException if {@code srcPos + nBytes > src.length}.
      */
-    public static int byteArrayToInt(final byte[] src, final int srcPos, final int dstInit, final int dstPos,
-            final int nBytes) {
+    public static int byteArrayToInt(final byte[] src, final int srcPos, final int dstInit, final int dstPos, final int nBytes) {
         if (src.length == 0 && srcPos == 0 || 0 == nBytes) {
             return dstInit;
         }
@@ -434,22 +407,19 @@ public static int byteArrayToInt(final byte[] src, final int srcPos, final int d
     }
 
     /**
-     * Converts an array of byte into a long using the default (little-endian, Lsb0) byte and
-     * bit ordering.
+     * Converts an array of byte into a long using the default (little-endian, Lsb0) byte and bit ordering.
      *
-     * @param src the byte array to convert
-     * @param srcPos the position in {@code src}, in byte unit, from where to start the
-     *            conversion
-     * @param dstInit initial value of the destination long
-     * @param dstPos the position of the LSB, in bits, in the result long
-     * @param nBytes the number of bytes to convert
-     * @return a long containing the selected bits
-     * @throws NullPointerException if {@code src} is {@code null}
-     * @throws IllegalArgumentException if {@code (nBytes-1)*8+dstPos >= 64}
-     * @throws ArrayIndexOutOfBoundsException if {@code srcPos + nBytes > src.length}
+     * @param src     the byte array to convert.
+     * @param srcPos  the position in {@code src}, in byte unit, from where to start the conversion.
+     * @param dstInit initial value of the destination long.
+     * @param dstPos  the position of the LSB, in bits, in the result long.
+     * @param nBytes  the number of bytes to convert.
+     * @return a long containing the selected bits.
+     * @throws NullPointerException           if {@code src} is {@code null}.
+     * @throws IllegalArgumentException       if {@code (nBytes-1)*8+dstPos >= 64}.
+     * @throws ArrayIndexOutOfBoundsException if {@code srcPos + nBytes > src.length}.
      */
-    public static long byteArrayToLong(final byte[] src, final int srcPos, final long dstInit, final int dstPos,
-            final int nBytes) {
+    public static long byteArrayToLong(final byte[] src, final int srcPos, final long dstInit, final int dstPos, final int nBytes) {
         if (src.length == 0 && srcPos == 0 || 0 == nBytes) {
             return dstInit;
         }
@@ -467,22 +437,19 @@ public static long byteArrayToLong(final byte[] src, final int srcPos, final lon
     }
 
     /**
-     * Converts an array of byte into a short using the default (little-endian, Lsb0) byte and
-     * bit ordering.
+     * Converts an array of byte into a short using the default (little-endian, Lsb0) byte and bit ordering.
      *
-     * @param src the byte array to convert
-     * @param srcPos the position in {@code src}, in byte unit, from where to start the
-     *            conversion
-     * @param dstInit initial value of the destination short
-     * @param dstPos the position of the LSB, in bits, in the result short
-     * @param nBytes the number of bytes to convert
-     * @return a short containing the selected bits
-     * @throws NullPointerException if {@code src} is {@code null}
-     * @throws IllegalArgumentException if {@code (nBytes-1)*8+dstPos >= 16}
-     * @throws ArrayIndexOutOfBoundsException if {@code srcPos + nBytes > src.length}
+     * @param src     the byte array to convert.
+     * @param srcPos  the position in {@code src}, in byte unit, from where to start the conversion.
+     * @param dstInit initial value of the destination short.
+     * @param dstPos  the position of the LSB, in bits, in the result short.
+     * @param nBytes  the number of bytes to convert.
+     * @return a short containing the selected bits.
+     * @throws NullPointerException           if {@code src} is {@code null}.
+     * @throws IllegalArgumentException       if {@code (nBytes-1)*8+dstPos >= 16}.
+     * @throws ArrayIndexOutOfBoundsException if {@code srcPos + nBytes > src.length}.
      */
-    public static short byteArrayToShort(final byte[] src, final int srcPos, final short dstInit, final int dstPos,
-            final int nBytes) {
+    public static short byteArrayToShort(final byte[] src, final int srcPos, final short dstInit, final int dstPos, final int nBytes) {
         if (src.length == 0 && srcPos == 0 || 0 == nBytes) {
             return dstInit;
         }
@@ -500,15 +467,13 @@ public static short byteArrayToShort(final byte[] src, final int srcPos, final s
     }
 
     /**
-     * Converts bytes from an array into a UUID using the default (little-endian, Lsb0) byte and
-     * bit ordering.
+     * Converts bytes from an array into a UUID using the default (little-endian, Lsb0) byte and bit ordering.
      *
-     * @param src the byte array to convert
-     * @param srcPos the position in {@code src} where to copy the result from
-     * @return a UUID
-     * @throws NullPointerException if {@code src} is {@code null}
-     * @throws IllegalArgumentException if array does not contain at least 16 bytes beginning
-     *             with {@code srcPos}
+     * @param src    the byte array to convert.
+     * @param srcPos the position in {@code src} where to copy the result from.
+     * @return a UUID.
+     * @throws NullPointerException     if {@code src} is {@code null}.
+     * @throws IllegalArgumentException if array does not contain at least 16 bytes beginning with {@code srcPos}.
      */
     public static UUID byteArrayToUuid(final byte[] src, final int srcPos) {
         if (src.length - srcPos < 16) {
@@ -518,22 +483,19 @@ public static UUID byteArrayToUuid(final byte[] src, final int srcPos) {
     }
 
     /**
-     * Converts a byte into an array of boolean using the default (little-endian, Lsb0) byte and
-     * bit ordering.
+     * Converts a byte into an array of boolean using the default (little-endian, Lsb0) byte and bit ordering.
      *
-     * @param src the byte to convert
-     * @param srcPos the position in {@code src}, in bits, from where to start the conversion
-     * @param dst the destination array
-     * @param dstPos the position in {@code dst} where to copy the result
-     * @param nBools the number of booleans to copy to {@code dst}, must be smaller or equal to
-     *            the width of the input (from srcPos to MSB)
-     * @return {@code dst}
-     * @throws NullPointerException if {@code dst} is {@code null}
-     * @throws IllegalArgumentException if {@code nBools-1+srcPos >= 8}
-     * @throws ArrayIndexOutOfBoundsException if {@code dstPos + nBools > dst.length}
+     * @param src    the byte to convert.
+     * @param srcPos the position in {@code src}, in bits, from where to start the conversion.
+     * @param dst    the destination array.
+     * @param dstPos the position in {@code dst} where to copy the result.
+     * @param nBools the number of booleans to copy to {@code dst}, must be smaller or equal to the width of the input (from srcPos to MSB).
+     * @return {@code dst}.
+     * @throws NullPointerException           if {@code dst} is {@code null}.
+     * @throws IllegalArgumentException       if {@code nBools-1+srcPos >= 8}.
+     * @throws ArrayIndexOutOfBoundsException if {@code dstPos + nBools > dst.length}.
      */
-    public static boolean[] byteToBinary(final byte src, final int srcPos, final boolean[] dst, final int dstPos,
-            final int nBools) {
+    public static boolean[] byteToBinary(final byte src, final int srcPos, final boolean[] dst, final int dstPos, final int nBools) {
         if (0 == nBools) {
             return dst;
         }
@@ -548,21 +510,18 @@ public static boolean[] byteToBinary(final byte src, final int srcPos, final boo
     }
 
     /**
-     * Converts a byte into an array of Char using the default (little-endian, Lsb0) byte and
-     * bit ordering.
+     * Converts a byte into an array of char using the default (little-endian, Lsb0) byte and bit ordering.
      *
-     * @param src the byte to convert
-     * @param srcPos the position in {@code src}, in bits, from where to start the conversion
-     * @param dstInit the initial value for the result String
-     * @param dstPos the position in {@code dst} where to copy the result
-     * @param nHexs the number of chars to copy to {@code dst}, must be smaller or equal to the
-     *            width of the input (from srcPos to MSB)
-     * @return {@code dst}
-     * @throws IllegalArgumentException if {@code (nHexs-1)*4+srcPos >= 8}
-     * @throws StringIndexOutOfBoundsException if {@code dst.init.length() < dstPos}
+     * @param src     the byte to convert.
+     * @param srcPos  the position in {@code src}, in bits, from where to start the conversion.
+     * @param dstInit the initial value for the result String.
+     * @param dstPos  the position in {@code dst} where to copy the result.
+     * @param nHexs   the number of chars to copy to {@code dst}, must be smaller or equal to the width of the input (from srcPos to MSB).
+     * @return {@code dst}.
+     * @throws IllegalArgumentException        if {@code (nHexs-1)*4+srcPos >= 8}.
+     * @throws StringIndexOutOfBoundsException if {@code dst.init.length() < dstPos}.
      */
-    public static String byteToHex(final byte src, final int srcPos, final String dstInit, final int dstPos,
-            final int nHexs) {
+    public static String byteToHex(final byte src, final int srcPos, final String dstInit, final int dstPos, final int nHexs) {
         if (0 == nHexs) {
             return dstInit;
         }
@@ -585,16 +544,15 @@ public static String byteToHex(final byte src, final int srcPos, final String ds
     }
 
     /**
-     * Converts a hexadecimal digit into binary (represented as boolean array) using the Msb0
-     * bit ordering.
+     * Converts a hexadecimal digit into binary (represented as boolean array) using the Msb0 bit ordering.
      *
      * <p>
-     * '1' is converted as follow: (0, 0, 0, 1)
+     * '1' is converted as follow: (0, 0, 0, 1).
      * </p>
      *
-     * @param hexDigit the hexadecimal digit to convert
-     * @return a boolean array with the binary representation of {@code hexDigit}
-     * @throws IllegalArgumentException if {@code hexDigit} is not a hexadecimal digit
+     * @param hexDigit the hexadecimal digit to convert.
+     * @return a boolean array with the binary representation of {@code hexDigit}.
+     * @throws IllegalArgumentException if {@code hexDigit} is not a hexadecimal digit.
      */
     public static boolean[] hexDigitMsb0ToBinary(final char hexDigit) {
         switch (hexDigit) {
@@ -645,12 +603,12 @@ public static boolean[] hexDigitMsb0ToBinary(final char hexDigit) {
      * Converts a hexadecimal digit into an int using the Msb0 bit ordering.
      *
      * <p>
-     * '1' is converted to 8
+     * '1' is converted to 8.
      * </p>
      *
-     * @param hexDigit the hexadecimal digit to convert
-     * @return an int equals to {@code hexDigit}
-     * @throws IllegalArgumentException if {@code hexDigit} is not a hexadecimal digit
+     * @param hexDigit the hexadecimal digit to convert.
+     * @return an int equals to {@code hexDigit}.
+     * @throws IllegalArgumentException if {@code hexDigit} is not a hexadecimal digit.
      */
     public static int hexDigitMsb0ToInt(final char hexDigit) {
         switch (hexDigit) {
@@ -698,16 +656,15 @@ public static int hexDigitMsb0ToInt(final char hexDigit) {
     }
 
     /**
-     * Converts a hexadecimal digit into binary (represented as boolean array) using the default
-     * (Lsb0) bit ordering.
+     * Converts a hexadecimal digit into binary (represented as boolean array) using the default (Lsb0) bit ordering.
      *
      * <p>
-     * '1' is converted as follow: (1, 0, 0, 0)
+     * '1' is converted as follow: (1, 0, 0, 0).
      * </p>
      *
-     * @param hexDigit the hexadecimal digit to convert
-     * @return a boolean array with the binary representation of {@code hexDigit}
-     * @throws IllegalArgumentException if {@code hexDigit} is not a hexadecimal digit
+     * @param hexDigit the hexadecimal digit to convert.
+     * @return a boolean array with the binary representation of {@code hexDigit}.
+     * @throws IllegalArgumentException if {@code hexDigit} is not a hexadecimal digit.
      */
     public static boolean[] hexDigitToBinary(final char hexDigit) {
         switch (hexDigit) {
@@ -761,9 +718,9 @@ public static boolean[] hexDigitToBinary(final char hexDigit) {
      * '1' is converted to 1
      * </p>
      *
-     * @param hexDigit the hexadecimal digit to convert
-     * @return an int equals to {@code hexDigit}
-     * @throws IllegalArgumentException if {@code hexDigit} is not a hexadecimal digit
+     * @param hexDigit the hexadecimal digit to convert.
+     * @return an int equals to {@code hexDigit}.
+     * @throws IllegalArgumentException if {@code hexDigit} is not a hexadecimal digit.
      */
     public static int hexDigitToInt(final char hexDigit) {
         final int digit = Character.digit(hexDigit, 16);
@@ -776,14 +733,13 @@ public static int hexDigitToInt(final char hexDigit) {
     /**
      * Converts a hexadecimal string into a byte using the default (little-endian, Lsb0) byte and bit ordering.
      *
-     * @param src the hexadecimal string to convert
-     * @param srcPos the position in {@code src}, in Char unit, from where to start the
-     *            conversion
-     * @param dstInit initial value of the destination byte
-     * @param dstPos the position of the LSB, in bits, in the result byte
-     * @param nHex the number of Chars to convert
-     * @return a byte containing the selected bits
-     * @throws IllegalArgumentException if {@code (nHex-1)*4+dstPos >= 8}
+     * @param src     the hexadecimal string to convert.
+     * @param srcPos  the position in {@code src}, in char unit, from where to start the conversion.
+     * @param dstInit initial value of the destination byte.
+     * @param dstPos  the position of the LSB, in bits, in the result byte.
+     * @param nHex    the number of Chars to convert.
+     * @return a byte containing the selected bits.
+     * @throws IllegalArgumentException if {@code (nHex-1)*4+dstPos >= 8}.
      */
     public static byte hexToByte(final String src, final int srcPos, final byte dstInit, final int dstPos, final int nHex) {
         if (0 == nHex) {
@@ -803,17 +759,15 @@ public static byte hexToByte(final String src, final int srcPos, final byte dstI
     }
 
     /**
-     * Converts an array of Char into an int using the default (little-endian, Lsb0) byte and bit
-     * ordering.
+     * Converts an array of char into an int using the default (little-endian, Lsb0) byte and bit ordering.
      *
-     * @param src the hexadecimal string to convert
-     * @param srcPos the position in {@code src}, in char unit, from where to start the
-     *            conversion
-     * @param dstInit initial value of the destination int
-     * @param dstPos the position of the LSB, in bits, in the result int
-     * @param nHex the number of chars to convert
-     * @return an int containing the selected bits
-     * @throws IllegalArgumentException if {@code (nHexs-1)*4+dstPos >= 32}
+     * @param src     the hexadecimal string to convert.
+     * @param srcPos  the position in {@code src}, in char unit, from where to start the conversion.
+     * @param dstInit initial value of the destination int.
+     * @param dstPos  the position of the LSB, in bits, in the result int.
+     * @param nHex    the number of chars to convert.
+     * @return an int containing the selected bits.
+     * @throws IllegalArgumentException if {@code (nHexs-1)*4+dstPos >= 32}.
      */
     public static int hexToInt(final String src, final int srcPos, final int dstInit, final int dstPos, final int nHex) {
         if (0 == nHex) {
@@ -833,17 +787,15 @@ public static int hexToInt(final String src, final int srcPos, final int dstInit
     }
 
     /**
-     * Converts an array of Char into a long using the default (little-endian, Lsb0) byte and
-     * bit ordering.
+     * Converts an array of char into a long using the default (little-endian, Lsb0) byte and bit ordering.
      *
-     * @param src the hexadecimal string to convert
-     * @param srcPos the position in {@code src}, in char unit, from where to start the
-     *            conversion
-     * @param dstInit initial value of the destination long
-     * @param dstPos the position of the LSB, in bits, in the result long
-     * @param nHex the number of chars to convert
-     * @return a long containing the selected bits
-     * @throws IllegalArgumentException if {@code (nHexs-1)*4+dstPos >= 64}
+     * @param src     the hexadecimal string to convert.
+     * @param srcPos  the position in {@code src}, in char unit, from where to start the conversion.
+     * @param dstInit initial value of the destination long.
+     * @param dstPos  the position of the LSB, in bits, in the result long.
+     * @param nHex    the number of chars to convert.
+     * @return a long containing the selected bits.
+     * @throws IllegalArgumentException if {@code (nHexs-1)*4+dstPos >= 64}.
      */
     public static long hexToLong(final String src, final int srcPos, final long dstInit, final int dstPos, final int nHex) {
         if (0 == nHex) {
@@ -863,17 +815,15 @@ public static long hexToLong(final String src, final int srcPos, final long dstI
     }
 
     /**
-     * Converts an array of Char into a short using the default (little-endian, Lsb0) byte and
-     * bit ordering.
+     * Converts an array of char into a short using the default (little-endian, Lsb0) byte and bit ordering.
      *
-     * @param src the hexadecimal string to convert
-     * @param srcPos the position in {@code src}, in char unit, from where to start the
-     *            conversion
-     * @param dstInit initial value of the destination short
-     * @param dstPos the position of the LSB, in bits, in the result short
-     * @param nHex the number of chars to convert
-     * @return a short containing the selected bits
-     * @throws IllegalArgumentException if {@code (nHexs-1)*4+dstPos >= 16}
+     * @param src     the hexadecimal string to convert.
+     * @param srcPos  the position in {@code src}, in char unit, from where to start the conversion.
+     * @param dstInit initial value of the destination short.
+     * @param dstPos  the position of the LSB, in bits, in the result short.
+     * @param nHex    the number of chars to convert.
+     * @return a short containing the selected bits.
+     * @throws IllegalArgumentException if {@code (nHexs-1)*4+dstPos >= 16}.
      */
     public static short hexToShort(final String src, final int srcPos, final short dstInit, final int dstPos, final int nHex) {
         if (0 == nHex) {
@@ -893,22 +843,19 @@ public static short hexToShort(final String src, final int srcPos, final short d
     }
 
     /**
-     * Converts an array of int into a long using the default (little-endian, Lsb0) byte and bit
-     * ordering.
+     * Converts an array of int into a long using the default (little-endian, Lsb0) byte and bit ordering.
      *
-     * @param src the int array to convert
-     * @param srcPos the position in {@code src}, in int unit, from where to start the
-     *            conversion
-     * @param dstInit initial value of the destination long
-     * @param dstPos the position of the LSB, in bits, in the result long
-     * @param nInts the number of ints to convert
-     * @return a long containing the selected bits
-     * @throws IllegalArgumentException if {@code (nInts-1)*32+dstPos >= 64}
-     * @throws NullPointerException if {@code src} is {@code null}
-     * @throws ArrayIndexOutOfBoundsException if {@code srcPos + nInts > src.length}
+     * @param src     the int array to convert.
+     * @param srcPos  the position in {@code src}, in int unit, from where to start the conversion.
+     * @param dstInit initial value of the destination long.
+     * @param dstPos  the position of the LSB, in bits, in the result long.
+     * @param nInts   the number of ints to convert.
+     * @return a long containing the selected bits.
+     * @throws IllegalArgumentException       if {@code (nInts-1)*32+dstPos >= 64}.
+     * @throws NullPointerException           if {@code src} is {@code null}.
+     * @throws ArrayIndexOutOfBoundsException if {@code srcPos + nInts > src.length}.
      */
-    public static long intArrayToLong(final int[] src, final int srcPos, final long dstInit, final int dstPos,
-            final int nInts) {
+    public static long intArrayToLong(final int[] src, final int srcPos, final long dstInit, final int dstPos, final int nInts) {
         if (src.length == 0 && srcPos == 0 || 0 == nInts) {
             return dstInit;
         }
@@ -926,22 +873,19 @@ public static long intArrayToLong(final int[] src, final int srcPos, final long
     }
 
     /**
-     * Converts an int into an array of boolean using the default (little-endian, Lsb0) byte and
-     * bit ordering.
+     * Converts an int into an array of boolean using the default (little-endian, Lsb0) byte and bit ordering.
      *
-     * @param src the int to convert
-     * @param srcPos the position in {@code src}, in bits, from where to start the conversion
-     * @param dst the destination array
-     * @param dstPos the position in {@code dst} where to copy the result
-     * @param nBools the number of booleans to copy to {@code dst}, must be smaller or equal to
-     *            the width of the input (from srcPos to MSB)
-     * @return {@code dst}
-     * @throws NullPointerException if {@code dst} is {@code null}
-     * @throws IllegalArgumentException if {@code nBools-1+srcPos >= 32}
-     * @throws ArrayIndexOutOfBoundsException if {@code dstPos + nBools > dst.length}
+     * @param src    the int to convert.
+     * @param srcPos the position in {@code src}, in bits, from where to start the conversion.
+     * @param dst    the destination array.
+     * @param dstPos the position in {@code dst} where to copy the result.
+     * @param nBools the number of booleans to copy to {@code dst}, must be smaller or equal to the width of the input (from srcPos to MSB).
+     * @return {@code dst}.
+     * @throws NullPointerException           if {@code dst} is {@code null}.
+     * @throws IllegalArgumentException       if {@code nBools-1+srcPos >= 32}.
+     * @throws ArrayIndexOutOfBoundsException if {@code dstPos + nBools > dst.length}.
      */
-    public static boolean[] intToBinary(final int src, final int srcPos, final boolean[] dst, final int dstPos,
-            final int nBools) {
+    public static boolean[] intToBinary(final int src, final int srcPos, final boolean[] dst, final int dstPos, final int nBools) {
         if (0 == nBools) {
             return dst;
         }
@@ -956,22 +900,19 @@ public static boolean[] intToBinary(final int src, final int srcPos, final boole
     }
 
     /**
-     * Converts an int into an array of byte using the default (little-endian, Lsb0) byte and bit
-     * ordering.
+     * Converts an int into an array of byte using the default (little-endian, Lsb0) byte and bit ordering.
      *
-     * @param src the int to convert
-     * @param srcPos the position in {@code src}, in bits, from where to start the conversion
-     * @param dst the destination array
-     * @param dstPos the position in {@code dst} where to copy the result
-     * @param nBytes the number of bytes to copy to {@code dst}, must be smaller or equal to the
-     *            width of the input (from srcPos to MSB)
-     * @return {@code dst}
-     * @throws NullPointerException if {@code dst} is {@code null}
-     * @throws IllegalArgumentException if {@code (nBytes-1)*8+srcPos >= 32}
-     * @throws ArrayIndexOutOfBoundsException if {@code dstPos + nBytes > dst.length}
+     * @param src    the int to convert.
+     * @param srcPos the position in {@code src}, in bits, from where to start the conversion.
+     * @param dst    the destination array.
+     * @param dstPos the position in {@code dst} where to copy the result.
+     * @param nBytes the number of bytes to copy to {@code dst}, must be smaller or equal to the width of the input (from srcPos to MSB).
+     * @return {@code dst}.
+     * @throws NullPointerException           if {@code dst} is {@code null}.
+     * @throws IllegalArgumentException       if {@code (nBytes-1)*8+srcPos >= 32}.
+     * @throws ArrayIndexOutOfBoundsException if {@code dstPos + nBytes > dst.length}.
      */
-    public static byte[] intToByteArray(final int src, final int srcPos, final byte[] dst, final int dstPos,
-            final int nBytes) {
+    public static byte[] intToByteArray(final int src, final int srcPos, final byte[] dst, final int dstPos, final int nBytes) {
         if (0 == nBytes) {
             return dst;
         }
@@ -986,7 +927,7 @@ public static byte[] intToByteArray(final int src, final int srcPos, final byte[
     }
 
     /**
-     * Converts an int into an array of Char using the default (little-endian, Lsb0) byte and bit ordering.
+     * Converts an int into an array of char using the default (little-endian, Lsb0) byte and bit ordering.
      *
      * @param src     the int to convert.
      * @param srcPos  the position in {@code src}, in bits, from where to start the conversion.
@@ -997,8 +938,7 @@ public static byte[] intToByteArray(final int src, final int srcPos, final byte[
      * @throws IllegalArgumentException        if {@code (nHexs-1)*4+srcPos >= 32}.
      * @throws StringIndexOutOfBoundsException if {@code dst.init.length() < dstPos}.
      */
-    public static String intToHex(final int src, final int srcPos, final String dstInit, final int dstPos,
-            final int nHexs) {
+    public static String intToHex(final int src, final int srcPos, final String dstInit, final int dstPos, final int nHexs) {
         if (0 == nHexs) {
             return dstInit;
         }
@@ -1033,9 +973,9 @@ public static String intToHex(final int src, final int srcPos, final String dstI
      * 10 returns 'A' and so on...
      * </p>
      *
-     * @param nibble the 4 bits to convert
-     * @return a hexadecimal digit representing the 4 LSB of {@code nibble}
-     * @throws IllegalArgumentException if {@code nibble < 0} or {@code nibble > 15}
+     * @param nibble the 4 bits to convert.
+     * @return a hexadecimal digit representing the 4 LSB of {@code nibble}.
+     * @throws IllegalArgumentException if {@code nibble < 0} or {@code nibble > 15}.
      */
     public static char intToHexDigit(final int nibble) {
         final char c = Character.forDigit(nibble, 16);
@@ -1058,9 +998,9 @@ public static char intToHexDigit(final int nibble) {
      * 10 returns '5' and so on...
      * </p>
      *
-     * @param nibble the 4 bits to convert
-     * @return a hexadecimal digit representing the 4 LSB of {@code nibble}
-     * @throws IllegalArgumentException if {@code nibble < 0} or {@code nibble > 15}
+     * @param nibble the 4 bits to convert.
+     * @return a hexadecimal digit representing the 4 LSB of {@code nibble}.
+     * @throws IllegalArgumentException if {@code nibble < 0} or {@code nibble > 15}.
      */
     public static char intToHexDigitMsb0(final int nibble) {
         switch (nibble) {
@@ -1102,22 +1042,19 @@ public static char intToHexDigitMsb0(final int nibble) {
     }
 
     /**
-     * Converts an int into an array of short using the default (little-endian, Lsb0) byte and
-     * bit ordering.
+     * Converts an int into an array of short using the default (little-endian, Lsb0) byte and bit ordering.
      *
-     * @param src the int to convert
-     * @param srcPos the position in {@code src}, in bits, from where to start the conversion
-     * @param dst the destination array
-     * @param dstPos the position in {@code dst} where to copy the result
-     * @param nShorts the number of shorts to copy to {@code dst}, must be smaller or equal to
-     *            the width of the input (from srcPos to MSB)
-     * @return {@code dst}
-     * @throws NullPointerException if {@code dst} is {@code null}
-     * @throws IllegalArgumentException if {@code (nShorts-1)*16+srcPos >= 32}
-     * @throws ArrayIndexOutOfBoundsException if {@code dstPos + nShorts > dst.length}
+     * @param src     the int to convert.
+     * @param srcPos  the position in {@code src}, in bits, from where to start the conversion.
+     * @param dst     the destination array.
+     * @param dstPos  the position in {@code dst} where to copy the result.
+     * @param nShorts the number of shorts to copy to {@code dst}, must be smaller or equal to the width of the input (from srcPos to MSB).
+     * @return {@code dst}.
+     * @throws NullPointerException           if {@code dst} is {@code null}.
+     * @throws IllegalArgumentException       if {@code (nShorts-1)*16+srcPos >= 32}.
+     * @throws ArrayIndexOutOfBoundsException if {@code dstPos + nShorts > dst.length}.
      */
-    public static short[] intToShortArray(final int src, final int srcPos, final short[] dst, final int dstPos,
-            final int nShorts) {
+    public static short[] intToShortArray(final int src, final int srcPos, final short[] dst, final int dstPos, final int nShorts) {
         if (0 == nShorts) {
             return dst;
         }
@@ -1132,22 +1069,19 @@ public static short[] intToShortArray(final int src, final int srcPos, final sho
     }
 
     /**
-     * Converts a long into an array of boolean using the default (little-endian, Lsb0) byte and
-     * bit ordering.
+     * Converts a long into an array of boolean using the default (little-endian, Lsb0) byte and bit ordering.
      *
-     * @param src the long to convert
-     * @param srcPos the position in {@code src}, in bits, from where to start the conversion
-     * @param dst the destination array
-     * @param dstPos the position in {@code dst} where to copy the result
-     * @param nBools the number of booleans to copy to {@code dst}, must be smaller or equal to
-     *            the width of the input (from srcPos to MSB)
-     * @return {@code dst}
-     * @throws NullPointerException if {@code dst} is {@code null}
-     * @throws IllegalArgumentException if {@code nBools-1+srcPos >= 64}
-     * @throws ArrayIndexOutOfBoundsException if {@code dstPos + nBools > dst.length}
+     * @param src    the long to convert.
+     * @param srcPos the position in {@code src}, in bits, from where to start the conversion.
+     * @param dst    the destination array.
+     * @param dstPos the position in {@code dst} where to copy the result.
+     * @param nBools the number of booleans to copy to {@code dst}, must be smaller or equal to the width of the input (from srcPos to MSB).
+     * @return {@code dst}.
+     * @throws NullPointerException           if {@code dst} is {@code null}.
+     * @throws IllegalArgumentException       if {@code nBools-1+srcPos >= 64}.
+     * @throws ArrayIndexOutOfBoundsException if {@code dstPos + nBools > dst.length}.
      */
-    public static boolean[] longToBinary(final long src, final int srcPos, final boolean[] dst, final int dstPos,
-            final int nBools) {
+    public static boolean[] longToBinary(final long src, final int srcPos, final boolean[] dst, final int dstPos, final int nBools) {
         if (0 == nBools) {
             return dst;
         }
@@ -1162,22 +1096,19 @@ public static boolean[] longToBinary(final long src, final int srcPos, final boo
     }
 
     /**
-     * Converts a long into an array of byte using the default (little-endian, Lsb0) byte and
-     * bit ordering.
+     * Converts a long into an array of byte using the default (little-endian, Lsb0) byte and bit ordering.
      *
-     * @param src the long to convert
-     * @param srcPos the position in {@code src}, in bits, from where to start the conversion
-     * @param dst the destination array
-     * @param dstPos the position in {@code dst} where to copy the result
-     * @param nBytes the number of bytes to copy to {@code dst}, must be smaller or equal to the
-     *            width of the input (from srcPos to MSB)
-     * @return {@code dst}
-     * @throws NullPointerException if {@code dst} is {@code null}
-     * @throws IllegalArgumentException if {@code (nBytes-1)*8+srcPos >= 64}
-     * @throws ArrayIndexOutOfBoundsException if {@code dstPos + nBytes > dst.length}
+     * @param src    the long to convert.
+     * @param srcPos the position in {@code src}, in bits, from where to start the conversion.
+     * @param dst    the destination array.
+     * @param dstPos the position in {@code dst} where to copy the result.
+     * @param nBytes the number of bytes to copy to {@code dst}, must be smaller or equal to the width of the input (from srcPos to MSB).
+     * @return {@code dst}.
+     * @throws NullPointerException           if {@code dst} is {@code null}.
+     * @throws IllegalArgumentException       if {@code (nBytes-1)*8+srcPos >= 64}.
+     * @throws ArrayIndexOutOfBoundsException if {@code dstPos + nBytes > dst.length}.
      */
-    public static byte[] longToByteArray(final long src, final int srcPos, final byte[] dst, final int dstPos,
-            final int nBytes) {
+    public static byte[] longToByteArray(final long src, final int srcPos, final byte[] dst, final int dstPos, final int nBytes) {
         if (0 == nBytes) {
             return dst;
         }
@@ -1192,21 +1123,18 @@ public static byte[] longToByteArray(final long src, final int srcPos, final byt
     }
 
     /**
-     * Converts a long into an array of Char using the default (little-endian, Lsb0) byte and
-     * bit ordering.
+     * Converts a long into an array of char using the default (little-endian, Lsb0) byte and bit ordering.
      *
-     * @param src the long to convert
-     * @param srcPos the position in {@code src}, in bits, from where to start the conversion
-     * @param dstInit the initial value for the result String
-     * @param dstPos the position in {@code dst} where to copy the result
-     * @param nHexs the number of chars to copy to {@code dst}, must be smaller or equal to the
-     *            width of the input (from srcPos to MSB)
-     * @return {@code dst}
-     * @throws IllegalArgumentException if {@code (nHexs-1)*4+srcPos >= 64}
-     * @throws StringIndexOutOfBoundsException if {@code dst.init.length() < dstPos}
+     * @param src     the long to convert.
+     * @param srcPos  the position in {@code src}, in bits, from where to start the conversion.
+     * @param dstInit the initial value for the result String.
+     * @param dstPos  the position in {@code dst} where to copy the result.
+     * @param nHexs   the number of chars to copy to {@code dst}, must be smaller or equal to the width of the input (from srcPos to MSB).
+     * @return {@code dst}.
+     * @throws IllegalArgumentException        if {@code (nHexs-1)*4+srcPos >= 64}.
+     * @throws StringIndexOutOfBoundsException if {@code dst.init.length() < dstPos}.
      */
-    public static String longToHex(final long src, final int srcPos, final String dstInit, final int dstPos,
-            final int nHexs) {
+    public static String longToHex(final long src, final int srcPos, final String dstInit, final int dstPos, final int nHexs) {
         if (0 == nHexs) {
             return dstInit;
         }
@@ -1229,22 +1157,19 @@ public static String longToHex(final long src, final int srcPos, final String ds
     }
 
     /**
-     * Converts a long into an array of int using the default (little-endian, Lsb0) byte and bit
-     * ordering.
+     * Converts a long into an array of int using the default (little-endian, Lsb0) byte and bit ordering.
      *
-     * @param src the long to convert
-     * @param srcPos the position in {@code src}, in bits, from where to start the conversion
-     * @param dst the destination array
-     * @param dstPos the position in {@code dst} where to copy the result
-     * @param nInts the number of ints to copy to {@code dst}, must be smaller or equal to the
-     *            width of the input (from srcPos to MSB)
-     * @return {@code dst}
-     * @throws NullPointerException if {@code dst} is {@code null} and {@code nInts > 0}
-     * @throws IllegalArgumentException if {@code (nInts-1)*32+srcPos >= 64}
-     * @throws ArrayIndexOutOfBoundsException if {@code dstPos + nInts > dst.length}
+     * @param src    the long to convert.
+     * @param srcPos the position in {@code src}, in bits, from where to start the conversion.
+     * @param dst    the destination array.
+     * @param dstPos the position in {@code dst} where to copy the result.
+     * @param nInts  the number of ints to copy to {@code dst}, must be smaller or equal to the width of the input (from srcPos to MSB).
+     * @return {@code dst}.
+     * @throws NullPointerException           if {@code dst} is {@code null} and {@code nInts > 0}.
+     * @throws IllegalArgumentException       if {@code (nInts-1)*32+srcPos >= 64}.
+     * @throws ArrayIndexOutOfBoundsException if {@code dstPos + nInts > dst.length}.
      */
-    public static int[] longToIntArray(final long src, final int srcPos, final int[] dst, final int dstPos,
-            final int nInts) {
+    public static int[] longToIntArray(final long src, final int srcPos, final int[] dst, final int dstPos, final int nInts) {
         if (0 == nInts) {
             return dst;
         }
@@ -1259,22 +1184,19 @@ public static int[] longToIntArray(final long src, final int srcPos, final int[]
     }
 
     /**
-     * Converts a long into an array of short using the default (little-endian, Lsb0) byte and
-     * bit ordering.
+     * Converts a long into an array of short using the default (little-endian, Lsb0) byte and bit ordering.
      *
-     * @param src the long to convert
-     * @param srcPos the position in {@code src}, in bits, from where to start the conversion
-     * @param dst the destination array
-     * @param dstPos the position in {@code dst} where to copy the result
-     * @param nShorts the number of shorts to copy to {@code dst}, must be smaller or equal to
-     *            the width of the input (from srcPos to MSB)
-     * @return {@code dst}
-     * @throws NullPointerException if {@code dst} is {@code null}
-     * @throws IllegalArgumentException if {@code (nShorts-1)*16+srcPos >= 64}
-     * @throws ArrayIndexOutOfBoundsException if {@code dstPos + nShorts > dst.length}
+     * @param src     the long to convert.
+     * @param srcPos  the position in {@code src}, in bits, from where to start the conversion.
+     * @param dst     the destination array.
+     * @param dstPos  the position in {@code dst} where to copy the result.
+     * @param nShorts the number of shorts to copy to {@code dst}, must be smaller or equal to the width of the input (from srcPos to MSB).
+     * @return {@code dst}.
+     * @throws NullPointerException           if {@code dst} is {@code null}.
+     * @throws IllegalArgumentException       if {@code (nShorts-1)*16+srcPos >= 64}.
+     * @throws ArrayIndexOutOfBoundsException if {@code dstPos + nShorts > dst.length}.
      */
-    public static short[] longToShortArray(final long src, final int srcPos, final short[] dst, final int dstPos,
-            final int nShorts) {
+    public static short[] longToShortArray(final long src, final int srcPos, final short[] dst, final int dstPos, final int nShorts) {
         if (0 == nShorts) {
             return dst;
         }
@@ -1289,22 +1211,19 @@ public static short[] longToShortArray(final long src, final int srcPos, final s
     }
 
     /**
-     * Converts an array of short into an int using the default (little-endian, Lsb0) byte and
-     * bit ordering.
+     * Converts an array of short into an int using the default (little-endian, Lsb0) byte and bit ordering.
      *
-     * @param src the short array to convert
-     * @param srcPos the position in {@code src}, in short unit, from where to start the
-     *            conversion
-     * @param dstInit initial value of the destination int
-     * @param dstPos the position of the LSB, in bits, in the result int
-     * @param nShorts the number of shorts to convert
-     * @return an int containing the selected bits
-     * @throws NullPointerException if {@code src} is {@code null}
-     * @throws IllegalArgumentException if {@code (nShorts-1)*16+dstPos >= 32}
-     * @throws ArrayIndexOutOfBoundsException if {@code srcPos + nShorts > src.length}
+     * @param src     the short array to convert.
+     * @param srcPos  the position in {@code src}, in short unit, from where to start the conversion.
+     * @param dstInit initial value of the destination int.
+     * @param dstPos  the position of the LSB, in bits, in the result int.
+     * @param nShorts the number of shorts to convert.
+     * @return an int containing the selected bits.
+     * @throws NullPointerException           if {@code src} is {@code null}.
+     * @throws IllegalArgumentException       if {@code (nShorts-1)*16+dstPos >= 32}.
+     * @throws ArrayIndexOutOfBoundsException if {@code srcPos + nShorts > src.length}.
      */
-    public static int shortArrayToInt(final short[] src, final int srcPos, final int dstInit, final int dstPos,
-            final int nShorts) {
+    public static int shortArrayToInt(final short[] src, final int srcPos, final int dstInit, final int dstPos, final int nShorts) {
         if (src.length == 0 && srcPos == 0 || 0 == nShorts) {
             return dstInit;
         }
@@ -1322,22 +1241,19 @@ public static int shortArrayToInt(final short[] src, final int srcPos, final int
     }
 
     /**
-     * Converts an array of short into a long using the default (little-endian, Lsb0) byte and
-     * bit ordering.
+     * Converts an array of short into a long using the default (little-endian, Lsb0) byte and bit ordering.
      *
-     * @param src the short array to convert
-     * @param srcPos the position in {@code src}, in short unit, from where to start the
-     *            conversion
-     * @param dstInit initial value of the destination long
-     * @param dstPos the position of the LSB, in bits, in the result long
-     * @param nShorts the number of shorts to convert
-     * @return a long containing the selected bits
-     * @throws NullPointerException if {@code src} is {@code null}
-     * @throws IllegalArgumentException if {@code (nShorts-1)*16+dstPos >= 64}
-     * @throws ArrayIndexOutOfBoundsException if {@code srcPos + nShorts > src.length}
+     * @param src     the short array to convert.
+     * @param srcPos  the position in {@code src}, in short unit, from where to start the conversion.
+     * @param dstInit initial value of the destination long.
+     * @param dstPos  the position of the LSB, in bits, in the result long.
+     * @param nShorts the number of shorts to convert.
+     * @return a long containing the selected bits.
+     * @throws NullPointerException           if {@code src} is {@code null}.
+     * @throws IllegalArgumentException       if {@code (nShorts-1)*16+dstPos >= 64}.
+     * @throws ArrayIndexOutOfBoundsException if {@code srcPos + nShorts > src.length}.
      */
-    public static long shortArrayToLong(final short[] src, final int srcPos, final long dstInit, final int dstPos,
-            final int nShorts) {
+    public static long shortArrayToLong(final short[] src, final int srcPos, final long dstInit, final int dstPos, final int nShorts) {
         if (src.length == 0 && srcPos == 0 || 0 == nShorts) {
             return dstInit;
         }
@@ -1355,22 +1271,19 @@ public static long shortArrayToLong(final short[] src, final int srcPos, final l
     }
 
     /**
-     * Converts a short into an array of boolean using the default (little-endian, Lsb0) byte
-     * and bit ordering.
+     * Converts a short into an array of boolean using the default (little-endian, Lsb0) byte and bit ordering.
      *
-     * @param src the short to convert
-     * @param srcPos the position in {@code src}, in bits, from where to start the conversion
-     * @param dst the destination array
-     * @param dstPos the position in {@code dst} where to copy the result
-     * @param nBools the number of booleans to copy to {@code dst}, must be smaller or equal to
-     *            the width of the input (from srcPos to MSB)
-     * @return {@code dst}
-     * @throws NullPointerException if {@code dst} is {@code null}
-     * @throws IllegalArgumentException if {@code nBools-1+srcPos >= 16}
-     * @throws ArrayIndexOutOfBoundsException if {@code dstPos + nBools > dst.length}
+     * @param src    the short to convert.
+     * @param srcPos the position in {@code src}, in bits, from where to start the conversion.
+     * @param dst    the destination array.
+     * @param dstPos the position in {@code dst} where to copy the result.
+     * @param nBools the number of booleans to copy to {@code dst}, must be smaller or equal to the width of the input (from srcPos to MSB).
+     * @return {@code dst}.
+     * @throws NullPointerException           if {@code dst} is {@code null}.
+     * @throws IllegalArgumentException       if {@code nBools-1+srcPos >= 16}.
+     * @throws ArrayIndexOutOfBoundsException if {@code dstPos + nBools > dst.length}.
      */
-    public static boolean[] shortToBinary(final short src, final int srcPos, final boolean[] dst, final int dstPos,
-            final int nBools) {
+    public static boolean[] shortToBinary(final short src, final int srcPos, final boolean[] dst, final int dstPos, final int nBools) {
         if (0 == nBools) {
             return dst;
         }
@@ -1386,22 +1299,19 @@ public static boolean[] shortToBinary(final short src, final int srcPos, final b
     }
 
     /**
-     * Converts a short into an array of byte using the default (little-endian, Lsb0) byte and
-     * bit ordering.
+     * Converts a short into an array of byte using the default (little-endian, Lsb0) byte and bit ordering.
      *
-     * @param src the short to convert
-     * @param srcPos the position in {@code src}, in bits, from where to start the conversion
-     * @param dst the destination array
-     * @param dstPos the position in {@code dst} where to copy the result
-     * @param nBytes the number of bytes to copy to {@code dst}, must be smaller or equal to the
-     *            width of the input (from srcPos to MSB)
-     * @return {@code dst}
-     * @throws NullPointerException if {@code dst} is {@code null}
-     * @throws IllegalArgumentException if {@code (nBytes-1)*8+srcPos >= 16}
-     * @throws ArrayIndexOutOfBoundsException if {@code dstPos + nBytes > dst.length}
+     * @param src    the short to convert.
+     * @param srcPos the position in {@code src}, in bits, from where to start the conversion.
+     * @param dst    the destination array.
+     * @param dstPos the position in {@code dst} where to copy the result.
+     * @param nBytes the number of bytes to copy to {@code dst}, must be smaller or equal to the width of the input (from srcPos to MSB).
+     * @return {@code dst}.
+     * @throws NullPointerException           if {@code dst} is {@code null}.
+     * @throws IllegalArgumentException       if {@code (nBytes-1)*8+srcPos >= 16}.
+     * @throws ArrayIndexOutOfBoundsException if {@code dstPos + nBytes > dst.length}.
      */
-    public static byte[] shortToByteArray(final short src, final int srcPos, final byte[] dst, final int dstPos,
-            final int nBytes) {
+    public static byte[] shortToByteArray(final short src, final int srcPos, final byte[] dst, final int dstPos, final int nBytes) {
         if (0 == nBytes) {
             return dst;
         }
@@ -1416,21 +1326,18 @@ public static byte[] shortToByteArray(final short src, final int srcPos, final b
     }
 
     /**
-     * Converts a short into an array of Char using the default (little-endian, Lsb0) byte and
-     * bit ordering.
+     * Converts a short into an array of char using the default (little-endian, Lsb0) byte and bit ordering.
      *
-     * @param src the short to convert
-     * @param srcPos the position in {@code src}, in bits, from where to start the conversion
-     * @param dstInit the initial value for the result String
-     * @param dstPos the position in {@code dst} where to copy the result
-     * @param nHexs the number of chars to copy to {@code dst}, must be smaller or equal to the
-     *            width of the input (from srcPos to MSB)
-     * @return {@code dst}
-     * @throws IllegalArgumentException if {@code (nHexs-1)*4+srcPos >= 16}
-     * @throws StringIndexOutOfBoundsException if {@code dst.init.length() < dstPos}
+     * @param src     the short to convert.
+     * @param srcPos  the position in {@code src}, in bits, from where to start the conversion.
+     * @param dstInit the initial value for the result String.
+     * @param dstPos  the position in {@code dst} where to copy the result.
+     * @param nHexs   the number of chars to copy to {@code dst}, must be smaller or equal to the width of the input (from srcPos to MSB).
+     * @return {@code dst}.
+     * @throws IllegalArgumentException        if {@code (nHexs-1)*4+srcPos >= 16}.
+     * @throws StringIndexOutOfBoundsException if {@code dst.init.length() < dstPos}.
      */
-    public static String shortToHex(final short src, final int srcPos, final String dstInit, final int dstPos,
-            final int nHexs) {
+    public static String shortToHex(final short src, final int srcPos, final String dstInit, final int dstPos, final int nHexs) {
         if (0 == nHexs) {
             return dstInit;
         }
@@ -1453,18 +1360,16 @@ public static String shortToHex(final short src, final int srcPos, final String
     }
 
     /**
-     * Converts UUID into an array of byte using the default (little-endian, Lsb0) byte and bit
-     * ordering.
+     * Converts UUID into an array of byte using the default (little-endian, Lsb0) byte and bit ordering.
      *
-     * @param src the UUID to convert
-     * @param dst the destination array
-     * @param dstPos the position in {@code dst} where to copy the result
-     * @param nBytes the number of bytes to copy to {@code dst}, must be smaller or equal to the
-     *            width of the input (from srcPos to MSB)
-     * @return {@code dst}
-     * @throws NullPointerException if {@code dst} is {@code null}
-     * @throws IllegalArgumentException if {@code nBytes > 16}
-     * @throws ArrayIndexOutOfBoundsException if {@code dstPos + nBytes > dst.length}
+     * @param src    the UUID to convert.
+     * @param dst    the destination array.
+     * @param dstPos the position in {@code dst} where to copy the result.
+     * @param nBytes the number of bytes to copy to {@code dst}, must be smaller or equal to the width of the input (from srcPos to MSB).
+     * @return {@code dst}.
+     * @throws NullPointerException           if {@code dst} is {@code null}.
+     * @throws IllegalArgumentException       if {@code nBytes > 16}.
+     * @throws ArrayIndexOutOfBoundsException if {@code dstPos + nBytes > dst.length}.
      */
     public static byte[] uuidToByteArray(final UUID src, final byte[] dst, final int dstPos, final int nBytes) {
         if (0 == nBytes) {


(commons-lang) 05/06: Better Javadoc and exception messages

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-lang.git

commit 42fef8bdbdaa0956b1dd5140ee3d511de4f62eb4
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Wed Sep 3 08:13:51 2025 -0400

    Better Javadoc and exception messages
    
    Add some test fixtures
---
 .../java/org/apache/commons/lang3/Conversion.java  | 148 ++++++++++-----------
 .../org/apache/commons/lang3/ConversionTest.java   |  62 +++------
 2 files changed, 95 insertions(+), 115 deletions(-)

diff --git a/src/main/java/org/apache/commons/lang3/Conversion.java b/src/main/java/org/apache/commons/lang3/Conversion.java
index 3ccc8c7ba..4f08eb5cf 100644
--- a/src/main/java/org/apache/commons/lang3/Conversion.java
+++ b/src/main/java/org/apache/commons/lang3/Conversion.java
@@ -149,7 +149,7 @@ public static char binaryBeMsb0ToHexDigit(final boolean[] src, final int srcPos)
      * @param nBools  the number of booleans to convert.
      * @return a byte containing the selected bits.
      * @throws NullPointerException           if {@code src} is {@code null}.
-     * @throws IllegalArgumentException       if {@code nBools-1+dstPos >= 8}.
+     * @throws IllegalArgumentException       if {@code nBools - 1 + dstPos >= 8}.
      * @throws ArrayIndexOutOfBoundsException if {@code srcPos + nBools > src.length}.
      */
     public static byte binaryToByte(final boolean[] src, final int srcPos, final byte dstInit, final int dstPos, final int nBools) {
@@ -157,7 +157,7 @@ public static byte binaryToByte(final boolean[] src, final int srcPos, final byt
             return dstInit;
         }
         if (nBools - 1 + dstPos >= 8) {
-            throw new IllegalArgumentException("nBools-1+dstPos is greater or equal to than 8");
+            throw new IllegalArgumentException("nBools - 1 + dstPos >= 8");
         }
         byte out = dstInit;
         for (int i = 0; i < nBools; i++) {
@@ -257,10 +257,10 @@ public static char binaryToHexDigitMsb0_4bits(final boolean[] src) {
      */
     public static char binaryToHexDigitMsb0_4bits(final boolean[] src, final int srcPos) {
         if (src.length > 8) {
-            throw new IllegalArgumentException("src.length>8: src.length=" + src.length);
+            throw new IllegalArgumentException("src.length > 8: src.length=" + src.length);
         }
         if (src.length - srcPos < 4) {
-            throw new IllegalArgumentException("src.length-srcPos<4: src.length=" + src.length + ", srcPos=" + srcPos);
+            throw new IllegalArgumentException("src.length - srcPos < 4: src.length=" + src.length + ", srcPos=" + srcPos);
         }
         if (src[srcPos + 3]) {
             if (src[srcPos + 2]) {
@@ -296,7 +296,7 @@ public static char binaryToHexDigitMsb0_4bits(final boolean[] src, final int src
      * @param nBools  the number of booleans to convert.
      * @return an int containing the selected bits.
      * @throws NullPointerException           if {@code src} is {@code null}.
-     * @throws IllegalArgumentException       if {@code nBools-1+dstPos >= 32}.
+     * @throws IllegalArgumentException       if {@code nBools - 1 + dstPos >= 32}.
      * @throws ArrayIndexOutOfBoundsException if {@code srcPos + nBools > src.length}.
      */
     public static int binaryToInt(final boolean[] src, final int srcPos, final int dstInit, final int dstPos, final int nBools) {
@@ -304,7 +304,7 @@ public static int binaryToInt(final boolean[] src, final int srcPos, final int d
             return dstInit;
         }
         if (nBools - 1 + dstPos >= 32) {
-            throw new IllegalArgumentException("nBools-1+dstPos is greater or equal to than 32");
+            throw new IllegalArgumentException("nBools - 1 + dstPos >= 32");
         }
         int out = dstInit;
         for (int i = 0; i < nBools; i++) {
@@ -326,7 +326,7 @@ public static int binaryToInt(final boolean[] src, final int srcPos, final int d
      * @param nBools  the number of booleans to convert.
      * @return a long containing the selected bits.
      * @throws NullPointerException           if {@code src} is {@code null}.
-     * @throws IllegalArgumentException       if {@code nBools-1+dstPos >= 64}.
+     * @throws IllegalArgumentException       if {@code nBools - 1 + dstPos >= 64}.
      * @throws ArrayIndexOutOfBoundsException if {@code srcPos + nBools > src.length}.
      */
     public static long binaryToLong(final boolean[] src, final int srcPos, final long dstInit, final int dstPos, final int nBools) {
@@ -334,7 +334,7 @@ public static long binaryToLong(final boolean[] src, final int srcPos, final lon
             return dstInit;
         }
         if (nBools - 1 + dstPos >= 64) {
-            throw new IllegalArgumentException("nBools-1+dstPos is greater or equal to than 64");
+            throw new IllegalArgumentException("nBools - 1 + dstPos >= 64");
         }
         long out = dstInit;
         for (int i = 0; i < nBools; i++) {
@@ -356,7 +356,7 @@ public static long binaryToLong(final boolean[] src, final int srcPos, final lon
      * @param nBools  the number of booleans to convert.
      * @return a short containing the selected bits.
      * @throws NullPointerException           if {@code src} is {@code null}.
-     * @throws IllegalArgumentException       if {@code nBools-1+dstPos >= 16}.
+     * @throws IllegalArgumentException       if {@code nBools - 1 + dstPos >= 16}.
      * @throws ArrayIndexOutOfBoundsException if {@code srcPos + nBools > src.length}.
      */
     public static short binaryToShort(final boolean[] src, final int srcPos, final short dstInit, final int dstPos, final int nBools) {
@@ -364,7 +364,7 @@ public static short binaryToShort(final boolean[] src, final int srcPos, final s
             return dstInit;
         }
         if (nBools - 1 + dstPos >= 16) {
-            throw new IllegalArgumentException("nBools-1+dstPos is greater or equal to than 16");
+            throw new IllegalArgumentException("nBools - 1 + dstPos >= 16");
         }
         short out = dstInit;
         for (int i = 0; i < nBools; i++) {
@@ -386,7 +386,7 @@ public static short binaryToShort(final boolean[] src, final int srcPos, final s
      * @param nBytes  the number of bytes to convert.
      * @return an int containing the selected bits.
      * @throws NullPointerException           if {@code src} is {@code null}.
-     * @throws IllegalArgumentException       if {@code (nBytes-1)*8+dstPos >= 32}.
+     * @throws IllegalArgumentException       if {@code (nBytes - 1) * 8 + dstPos >= 32}.
      * @throws ArrayIndexOutOfBoundsException if {@code srcPos + nBytes > src.length}.
      */
     public static int byteArrayToInt(final byte[] src, final int srcPos, final int dstInit, final int dstPos, final int nBytes) {
@@ -394,7 +394,7 @@ public static int byteArrayToInt(final byte[] src, final int srcPos, final int d
             return dstInit;
         }
         if ((nBytes - 1) * 8 + dstPos >= 32) {
-            throw new IllegalArgumentException("(nBytes-1)*8+dstPos is greater or equal to than 32");
+            throw new IllegalArgumentException("(nBytes - 1) * 8 + dstPos >= 32");
         }
         int out = dstInit;
         for (int i = 0; i < nBytes; i++) {
@@ -416,7 +416,7 @@ public static int byteArrayToInt(final byte[] src, final int srcPos, final int d
      * @param nBytes  the number of bytes to convert.
      * @return a long containing the selected bits.
      * @throws NullPointerException           if {@code src} is {@code null}.
-     * @throws IllegalArgumentException       if {@code (nBytes-1)*8+dstPos >= 64}.
+     * @throws IllegalArgumentException       if {@code (nBytes - 1) * 8 + dstPos >= 64}.
      * @throws ArrayIndexOutOfBoundsException if {@code srcPos + nBytes > src.length}.
      */
     public static long byteArrayToLong(final byte[] src, final int srcPos, final long dstInit, final int dstPos, final int nBytes) {
@@ -424,7 +424,7 @@ public static long byteArrayToLong(final byte[] src, final int srcPos, final lon
             return dstInit;
         }
         if ((nBytes - 1) * 8 + dstPos >= 64) {
-            throw new IllegalArgumentException("(nBytes-1)*8+dstPos is greater or equal to than 64");
+            throw new IllegalArgumentException("(nBytes - 1) * 8 + dstPos >= 64");
         }
         long out = dstInit;
         for (int i = 0; i < nBytes; i++) {
@@ -446,7 +446,7 @@ public static long byteArrayToLong(final byte[] src, final int srcPos, final lon
      * @param nBytes  the number of bytes to convert.
      * @return a short containing the selected bits.
      * @throws NullPointerException           if {@code src} is {@code null}.
-     * @throws IllegalArgumentException       if {@code (nBytes-1)*8+dstPos >= 16}.
+     * @throws IllegalArgumentException       if {@code (nBytes - 1) * 8 + dstPos >= 16}.
      * @throws ArrayIndexOutOfBoundsException if {@code srcPos + nBytes > src.length}.
      */
     public static short byteArrayToShort(final byte[] src, final int srcPos, final short dstInit, final int dstPos, final int nBytes) {
@@ -454,7 +454,7 @@ public static short byteArrayToShort(final byte[] src, final int srcPos, final s
             return dstInit;
         }
         if ((nBytes - 1) * 8 + dstPos >= 16) {
-            throw new IllegalArgumentException("(nBytes-1)*8+dstPos is greater or equal to than 16");
+            throw new IllegalArgumentException("(nBytes - 1) * 8 + dstPos >= 16");
         }
         short out = dstInit;
         for (int i = 0; i < nBytes; i++) {
@@ -492,7 +492,7 @@ public static UUID byteArrayToUuid(final byte[] src, final int srcPos) {
      * @param nBools the number of booleans to copy to {@code dst}, must be smaller or equal to the width of the input (from srcPos to MSB).
      * @return {@code dst}.
      * @throws NullPointerException           if {@code dst} is {@code null}.
-     * @throws IllegalArgumentException       if {@code nBools-1+srcPos >= 8}.
+     * @throws IllegalArgumentException       if {@code nBools -  1 + srcPos >= 8}.
      * @throws ArrayIndexOutOfBoundsException if {@code dstPos + nBools > dst.length}.
      */
     public static boolean[] byteToBinary(final byte src, final int srcPos, final boolean[] dst, final int dstPos, final int nBools) {
@@ -500,7 +500,7 @@ public static boolean[] byteToBinary(final byte src, final int srcPos, final boo
             return dst;
         }
         if (nBools - 1 + srcPos >= 8) {
-            throw new IllegalArgumentException("nBools-1+srcPos is greater or equal to than 8");
+            throw new IllegalArgumentException("nBools -  1 + srcPos >= 8");
         }
         for (int i = 0; i < nBools; i++) {
             final int shift = i + srcPos;
@@ -518,7 +518,7 @@ public static boolean[] byteToBinary(final byte src, final int srcPos, final boo
      * @param dstPos  the position in {@code dst} where to copy the result.
      * @param nHexs   the number of chars to copy to {@code dst}, must be smaller or equal to the width of the input (from srcPos to MSB).
      * @return {@code dst}.
-     * @throws IllegalArgumentException        if {@code (nHexs-1)*4+srcPos >= 8}.
+     * @throws IllegalArgumentException        if {@code (nHexs - 1) * 4 + srcPos >= 8}.
      * @throws StringIndexOutOfBoundsException if {@code dst.init.length() < dstPos}.
      */
     public static String byteToHex(final byte src, final int srcPos, final String dstInit, final int dstPos, final int nHexs) {
@@ -526,7 +526,7 @@ public static String byteToHex(final byte src, final int srcPos, final String ds
             return dstInit;
         }
         if ((nHexs - 1) * 4 + srcPos >= 8) {
-            throw new IllegalArgumentException("(nHexs-1)*4+srcPos is greater or equal to than 8");
+            throw new IllegalArgumentException("(nHexs - 1) * 4 + srcPos >= 8");
         }
         final StringBuilder sb = new StringBuilder(dstInit);
         int append = sb.length();
@@ -550,12 +550,12 @@ public static String byteToHex(final byte src, final int srcPos, final String ds
      * '1' is converted as follow: (0, 0, 0, 1).
      * </p>
      *
-     * @param hexDigit the hexadecimal digit to convert.
+     * @param hexChar the hexadecimal digit to convert.
      * @return a boolean array with the binary representation of {@code hexDigit}.
      * @throws IllegalArgumentException if {@code hexDigit} is not a hexadecimal digit.
      */
-    public static boolean[] hexDigitMsb0ToBinary(final char hexDigit) {
-        switch (hexDigit) {
+    public static boolean[] hexDigitMsb0ToBinary(final char hexChar) {
+        switch (hexChar) {
         case '0':
             return FFFF.clone();
         case '1':
@@ -595,7 +595,7 @@ public static boolean[] hexDigitMsb0ToBinary(final char hexDigit) {
         case 'F':
             return TTTT.clone();
         default:
-            throw new IllegalArgumentException("Cannot interpret '" + hexDigit + "' as a hexadecimal digit");
+            throw new IllegalArgumentException("Cannot convert '" + hexChar + "' to a hexadecimal digit");
         }
     }
 
@@ -606,12 +606,12 @@ public static boolean[] hexDigitMsb0ToBinary(final char hexDigit) {
      * '1' is converted to 8.
      * </p>
      *
-     * @param hexDigit the hexadecimal digit to convert.
+     * @param hexChar the hexadecimal digit to convert.
      * @return an int equals to {@code hexDigit}.
      * @throws IllegalArgumentException if {@code hexDigit} is not a hexadecimal digit.
      */
-    public static int hexDigitMsb0ToInt(final char hexDigit) {
-        switch (hexDigit) {
+    public static int hexDigitMsb0ToInt(final char hexChar) {
+        switch (hexChar) {
         case '0':
             return 0x0;
         case '1':
@@ -651,7 +651,7 @@ public static int hexDigitMsb0ToInt(final char hexDigit) {
         case 'F':
             return 0xF;
         default:
-            throw new IllegalArgumentException("Cannot interpret '" + hexDigit + "' as a hexadecimal digit");
+            throw new IllegalArgumentException("Cannot convert '" + hexChar + "' to a hexadecimal digit");
         }
     }
 
@@ -662,12 +662,12 @@ public static int hexDigitMsb0ToInt(final char hexDigit) {
      * '1' is converted as follow: (1, 0, 0, 0).
      * </p>
      *
-     * @param hexDigit the hexadecimal digit to convert.
+     * @param hexChar the hexadecimal digit to convert.
      * @return a boolean array with the binary representation of {@code hexDigit}.
      * @throws IllegalArgumentException if {@code hexDigit} is not a hexadecimal digit.
      */
-    public static boolean[] hexDigitToBinary(final char hexDigit) {
-        switch (hexDigit) {
+    public static boolean[] hexDigitToBinary(final char hexChar) {
+        switch (hexChar) {
         case '0':
             return FFFF.clone();
         case '1':
@@ -707,7 +707,7 @@ public static boolean[] hexDigitToBinary(final char hexDigit) {
         case 'F':
             return TTTT.clone();
         default:
-            throw new IllegalArgumentException("Cannot interpret '" + hexDigit + "' as a hexadecimal digit");
+            throw new IllegalArgumentException("Cannot convert '" + hexChar + "' to a hexadecimal digit");
         }
     }
 
@@ -718,14 +718,14 @@ public static boolean[] hexDigitToBinary(final char hexDigit) {
      * '1' is converted to 1
      * </p>
      *
-     * @param hexDigit the hexadecimal digit to convert.
+     * @param hexChar the hexadecimal digit to convert.
      * @return an int equals to {@code hexDigit}.
      * @throws IllegalArgumentException if {@code hexDigit} is not a hexadecimal digit.
      */
-    public static int hexDigitToInt(final char hexDigit) {
-        final int digit = Character.digit(hexDigit, 16);
+    public static int hexDigitToInt(final char hexChar) {
+        final int digit = Character.digit(hexChar, 16);
         if (digit < 0) {
-            throw new IllegalArgumentException("Cannot interpret '" + hexDigit + "' as a hexadecimal digit");
+            throw new IllegalArgumentException("Cannot convert '" + hexChar + "' to a hexadecimal digit");
         }
         return digit;
     }
@@ -746,7 +746,7 @@ public static byte hexToByte(final String src, final int srcPos, final byte dstI
             return dstInit;
         }
         if ((nHex - 1) * 4 + dstPos >= 8) {
-            throw new IllegalArgumentException("(nHex - 1) * 4 + dstPos is greater than or equal to 8");
+            throw new IllegalArgumentException("(nHex - 1) * 4 + dstPos >= 8");
         }
         byte out = dstInit;
         for (int i = 0; i < nHex; i++) {
@@ -767,14 +767,14 @@ public static byte hexToByte(final String src, final int srcPos, final byte dstI
      * @param dstPos  the position of the LSB, in bits, in the result int.
      * @param nHex    the number of chars to convert.
      * @return an int containing the selected bits.
-     * @throws IllegalArgumentException if {@code (nHexs-1)*4+dstPos >= 32}.
+     * @throws IllegalArgumentException if {@code (nHexs - 1) * 4 + dstPos >= 32}.
      */
     public static int hexToInt(final String src, final int srcPos, final int dstInit, final int dstPos, final int nHex) {
         if (0 == nHex) {
             return dstInit;
         }
         if ((nHex - 1) * 4 + dstPos >= 32) {
-            throw new IllegalArgumentException("(nHexs-1)*4+dstPos is greater or equal to than 32");
+            throw new IllegalArgumentException("(nHexs - 1) * 4 + dstPos >= 32");
         }
         int out = dstInit;
         for (int i = 0; i < nHex; i++) {
@@ -795,14 +795,14 @@ public static int hexToInt(final String src, final int srcPos, final int dstInit
      * @param dstPos  the position of the LSB, in bits, in the result long.
      * @param nHex    the number of chars to convert.
      * @return a long containing the selected bits.
-     * @throws IllegalArgumentException if {@code (nHexs-1)*4+dstPos >= 64}.
+     * @throws IllegalArgumentException if {@code (nHexs - 1) * 4 + dstPos >= 64}.
      */
     public static long hexToLong(final String src, final int srcPos, final long dstInit, final int dstPos, final int nHex) {
         if (0 == nHex) {
             return dstInit;
         }
         if ((nHex - 1) * 4 + dstPos >= 64) {
-            throw new IllegalArgumentException("(nHexs-1)*4+dstPos is greater or equal to than 64");
+            throw new IllegalArgumentException("(nHexs - 1) * 4 + dstPos >= 64");
         }
         long out = dstInit;
         for (int i = 0; i < nHex; i++) {
@@ -823,14 +823,14 @@ public static long hexToLong(final String src, final int srcPos, final long dstI
      * @param dstPos  the position of the LSB, in bits, in the result short.
      * @param nHex    the number of chars to convert.
      * @return a short containing the selected bits.
-     * @throws IllegalArgumentException if {@code (nHexs-1)*4+dstPos >= 16}.
+     * @throws IllegalArgumentException if {@code (nHexs - 1) * 4 + dstPos >= 16}.
      */
     public static short hexToShort(final String src, final int srcPos, final short dstInit, final int dstPos, final int nHex) {
         if (0 == nHex) {
             return dstInit;
         }
         if ((nHex - 1) * 4 + dstPos >= 16) {
-            throw new IllegalArgumentException("(nHexs-1)*4+dstPos is greater or equal to than 16");
+            throw new IllegalArgumentException("(nHexs - 1) * 4 + dstPos >= 16");
         }
         short out = dstInit;
         for (int i = 0; i < nHex; i++) {
@@ -851,7 +851,7 @@ public static short hexToShort(final String src, final int srcPos, final short d
      * @param dstPos  the position of the LSB, in bits, in the result long.
      * @param nInts   the number of ints to convert.
      * @return a long containing the selected bits.
-     * @throws IllegalArgumentException       if {@code (nInts-1)*32+dstPos >= 64}.
+     * @throws IllegalArgumentException       if {@code (nInts - 1) * 32 + dstPos >= 64}.
      * @throws NullPointerException           if {@code src} is {@code null}.
      * @throws ArrayIndexOutOfBoundsException if {@code srcPos + nInts > src.length}.
      */
@@ -860,7 +860,7 @@ public static long intArrayToLong(final int[] src, final int srcPos, final long
             return dstInit;
         }
         if ((nInts - 1) * 32 + dstPos >= 64) {
-            throw new IllegalArgumentException("(nInts-1)*32+dstPos is greater or equal to than 64");
+            throw new IllegalArgumentException("(nInts - 1) * 32 + dstPos >= 64");
         }
         long out = dstInit;
         for (int i = 0; i < nInts; i++) {
@@ -882,7 +882,7 @@ public static long intArrayToLong(final int[] src, final int srcPos, final long
      * @param nBools the number of booleans to copy to {@code dst}, must be smaller or equal to the width of the input (from srcPos to MSB).
      * @return {@code dst}.
      * @throws NullPointerException           if {@code dst} is {@code null}.
-     * @throws IllegalArgumentException       if {@code nBools-1+srcPos >= 32}.
+     * @throws IllegalArgumentException       if {@code nBools -  1 + srcPos >= 32}.
      * @throws ArrayIndexOutOfBoundsException if {@code dstPos + nBools > dst.length}.
      */
     public static boolean[] intToBinary(final int src, final int srcPos, final boolean[] dst, final int dstPos, final int nBools) {
@@ -890,7 +890,7 @@ public static boolean[] intToBinary(final int src, final int srcPos, final boole
             return dst;
         }
         if (nBools - 1 + srcPos >= 32) {
-            throw new IllegalArgumentException("nBools-1+srcPos is greater or equal to than 32");
+            throw new IllegalArgumentException("nBools -  1 + srcPos >= 32");
         }
         for (int i = 0; i < nBools; i++) {
             final int shift = i + srcPos;
@@ -909,7 +909,7 @@ public static boolean[] intToBinary(final int src, final int srcPos, final boole
      * @param nBytes the number of bytes to copy to {@code dst}, must be smaller or equal to the width of the input (from srcPos to MSB).
      * @return {@code dst}.
      * @throws NullPointerException           if {@code dst} is {@code null}.
-     * @throws IllegalArgumentException       if {@code (nBytes-1)*8+srcPos >= 32}.
+     * @throws IllegalArgumentException       if {@code (nBytes - 1) * 8 + srcPos >= 32}.
      * @throws ArrayIndexOutOfBoundsException if {@code dstPos + nBytes > dst.length}.
      */
     public static byte[] intToByteArray(final int src, final int srcPos, final byte[] dst, final int dstPos, final int nBytes) {
@@ -917,7 +917,7 @@ public static byte[] intToByteArray(final int src, final int srcPos, final byte[
             return dst;
         }
         if ((nBytes - 1) * 8 + srcPos >= 32) {
-            throw new IllegalArgumentException("(nBytes-1)*8+srcPos is greater or equal to than 32");
+            throw new IllegalArgumentException("(nBytes - 1) * 8 + srcPos >= 32");
         }
         for (int i = 0; i < nBytes; i++) {
             final int shift = i * 8 + srcPos;
@@ -935,7 +935,7 @@ public static byte[] intToByteArray(final int src, final int srcPos, final byte[
      * @param dstPos  the position in {@code dst} where to copy the result.
      * @param nHexs   the number of chars to copy to {@code dst}, must be smaller or equal to the width of the input (from srcPos to MSB).
      * @return {@code dst}.
-     * @throws IllegalArgumentException        if {@code (nHexs-1)*4+srcPos >= 32}.
+     * @throws IllegalArgumentException        if {@code (nHexs - 1) * 4 + srcPos >= 32}.
      * @throws StringIndexOutOfBoundsException if {@code dst.init.length() < dstPos}.
      */
     public static String intToHex(final int src, final int srcPos, final String dstInit, final int dstPos, final int nHexs) {
@@ -943,7 +943,7 @@ public static String intToHex(final int src, final int srcPos, final String dstI
             return dstInit;
         }
         if ((nHexs - 1) * 4 + srcPos >= 32) {
-            throw new IllegalArgumentException("(nHexs-1)*4+srcPos is greater or equal to than 32");
+            throw new IllegalArgumentException("(nHexs - 1) * 4 + srcPos >= 32");
         }
         final StringBuilder sb = new StringBuilder(dstInit);
         int append = sb.length();
@@ -1051,7 +1051,7 @@ public static char intToHexDigitMsb0(final int nibble) {
      * @param nShorts the number of shorts to copy to {@code dst}, must be smaller or equal to the width of the input (from srcPos to MSB).
      * @return {@code dst}.
      * @throws NullPointerException           if {@code dst} is {@code null}.
-     * @throws IllegalArgumentException       if {@code (nShorts-1)*16+srcPos >= 32}.
+     * @throws IllegalArgumentException       if {@code (nShorts - 1) * 16 + srcPos >= 32}.
      * @throws ArrayIndexOutOfBoundsException if {@code dstPos + nShorts > dst.length}.
      */
     public static short[] intToShortArray(final int src, final int srcPos, final short[] dst, final int dstPos, final int nShorts) {
@@ -1059,7 +1059,7 @@ public static short[] intToShortArray(final int src, final int srcPos, final sho
             return dst;
         }
         if ((nShorts - 1) * 16 + srcPos >= 32) {
-            throw new IllegalArgumentException("(nShorts-1)*16+srcPos is greater or equal to than 32");
+            throw new IllegalArgumentException("(nShorts - 1) * 16 + srcPos >= 32");
         }
         for (int i = 0; i < nShorts; i++) {
             final int shift = i * 16 + srcPos;
@@ -1078,7 +1078,7 @@ public static short[] intToShortArray(final int src, final int srcPos, final sho
      * @param nBools the number of booleans to copy to {@code dst}, must be smaller or equal to the width of the input (from srcPos to MSB).
      * @return {@code dst}.
      * @throws NullPointerException           if {@code dst} is {@code null}.
-     * @throws IllegalArgumentException       if {@code nBools-1+srcPos >= 64}.
+     * @throws IllegalArgumentException       if {@code nBools -  1 + srcPos >= 64}.
      * @throws ArrayIndexOutOfBoundsException if {@code dstPos + nBools > dst.length}.
      */
     public static boolean[] longToBinary(final long src, final int srcPos, final boolean[] dst, final int dstPos, final int nBools) {
@@ -1086,7 +1086,7 @@ public static boolean[] longToBinary(final long src, final int srcPos, final boo
             return dst;
         }
         if (nBools - 1 + srcPos >= 64) {
-            throw new IllegalArgumentException("nBools-1+srcPos is greater or equal to than 64");
+            throw new IllegalArgumentException("nBools -  1 + srcPos >= 64");
         }
         for (int i = 0; i < nBools; i++) {
             final int shift = i + srcPos;
@@ -1105,7 +1105,7 @@ public static boolean[] longToBinary(final long src, final int srcPos, final boo
      * @param nBytes the number of bytes to copy to {@code dst}, must be smaller or equal to the width of the input (from srcPos to MSB).
      * @return {@code dst}.
      * @throws NullPointerException           if {@code dst} is {@code null}.
-     * @throws IllegalArgumentException       if {@code (nBytes-1)*8+srcPos >= 64}.
+     * @throws IllegalArgumentException       if {@code (nBytes - 1) * 8 + srcPos >= 64}.
      * @throws ArrayIndexOutOfBoundsException if {@code dstPos + nBytes > dst.length}.
      */
     public static byte[] longToByteArray(final long src, final int srcPos, final byte[] dst, final int dstPos, final int nBytes) {
@@ -1113,7 +1113,7 @@ public static byte[] longToByteArray(final long src, final int srcPos, final byt
             return dst;
         }
         if ((nBytes - 1) * 8 + srcPos >= 64) {
-            throw new IllegalArgumentException("(nBytes-1)*8+srcPos is greater or equal to than 64");
+            throw new IllegalArgumentException("(nBytes - 1) * 8 + srcPos >= 64");
         }
         for (int i = 0; i < nBytes; i++) {
             final int shift = i * 8 + srcPos;
@@ -1131,7 +1131,7 @@ public static byte[] longToByteArray(final long src, final int srcPos, final byt
      * @param dstPos  the position in {@code dst} where to copy the result.
      * @param nHexs   the number of chars to copy to {@code dst}, must be smaller or equal to the width of the input (from srcPos to MSB).
      * @return {@code dst}.
-     * @throws IllegalArgumentException        if {@code (nHexs-1)*4+srcPos >= 64}.
+     * @throws IllegalArgumentException        if {@code (nHexs - 1) * 4 + srcPos >= 64}.
      * @throws StringIndexOutOfBoundsException if {@code dst.init.length() < dstPos}.
      */
     public static String longToHex(final long src, final int srcPos, final String dstInit, final int dstPos, final int nHexs) {
@@ -1139,7 +1139,7 @@ public static String longToHex(final long src, final int srcPos, final String ds
             return dstInit;
         }
         if ((nHexs - 1) * 4 + srcPos >= 64) {
-            throw new IllegalArgumentException("(nHexs-1)*4+srcPos is greater or equal to than 64");
+            throw new IllegalArgumentException("(nHexs - 1) * 4 + srcPos >= 64");
         }
         final StringBuilder sb = new StringBuilder(dstInit);
         int append = sb.length();
@@ -1166,7 +1166,7 @@ public static String longToHex(final long src, final int srcPos, final String ds
      * @param nInts  the number of ints to copy to {@code dst}, must be smaller or equal to the width of the input (from srcPos to MSB).
      * @return {@code dst}.
      * @throws NullPointerException           if {@code dst} is {@code null} and {@code nInts > 0}.
-     * @throws IllegalArgumentException       if {@code (nInts-1)*32+srcPos >= 64}.
+     * @throws IllegalArgumentException       if {@code (nInts - 1) * 32 + srcPos >= 64}.
      * @throws ArrayIndexOutOfBoundsException if {@code dstPos + nInts > dst.length}.
      */
     public static int[] longToIntArray(final long src, final int srcPos, final int[] dst, final int dstPos, final int nInts) {
@@ -1174,7 +1174,7 @@ public static int[] longToIntArray(final long src, final int srcPos, final int[]
             return dst;
         }
         if ((nInts - 1) * 32 + srcPos >= 64) {
-            throw new IllegalArgumentException("(nInts-1)*32+srcPos is greater or equal to than 64");
+            throw new IllegalArgumentException("(nInts - 1) * 32 + srcPos >= 64");
         }
         for (int i = 0; i < nInts; i++) {
             final int shift = i * 32 + srcPos;
@@ -1193,7 +1193,7 @@ public static int[] longToIntArray(final long src, final int srcPos, final int[]
      * @param nShorts the number of shorts to copy to {@code dst}, must be smaller or equal to the width of the input (from srcPos to MSB).
      * @return {@code dst}.
      * @throws NullPointerException           if {@code dst} is {@code null}.
-     * @throws IllegalArgumentException       if {@code (nShorts-1)*16+srcPos >= 64}.
+     * @throws IllegalArgumentException       if {@code (nShorts - 1) * 16 + srcPos >= 64}.
      * @throws ArrayIndexOutOfBoundsException if {@code dstPos + nShorts > dst.length}.
      */
     public static short[] longToShortArray(final long src, final int srcPos, final short[] dst, final int dstPos, final int nShorts) {
@@ -1201,7 +1201,7 @@ public static short[] longToShortArray(final long src, final int srcPos, final s
             return dst;
         }
         if ((nShorts - 1) * 16 + srcPos >= 64) {
-            throw new IllegalArgumentException("(nShorts-1)*16+srcPos is greater or equal to than 64");
+            throw new IllegalArgumentException("(nShorts - 1) * 16 + srcPos >= 64");
         }
         for (int i = 0; i < nShorts; i++) {
             final int shift = i * 16 + srcPos;
@@ -1220,7 +1220,7 @@ public static short[] longToShortArray(final long src, final int srcPos, final s
      * @param nShorts the number of shorts to convert.
      * @return an int containing the selected bits.
      * @throws NullPointerException           if {@code src} is {@code null}.
-     * @throws IllegalArgumentException       if {@code (nShorts-1)*16+dstPos >= 32}.
+     * @throws IllegalArgumentException       if {@code (nShorts - 1) * 16 + dstPos >= 32}.
      * @throws ArrayIndexOutOfBoundsException if {@code srcPos + nShorts > src.length}.
      */
     public static int shortArrayToInt(final short[] src, final int srcPos, final int dstInit, final int dstPos, final int nShorts) {
@@ -1228,7 +1228,7 @@ public static int shortArrayToInt(final short[] src, final int srcPos, final int
             return dstInit;
         }
         if ((nShorts - 1) * 16 + dstPos >= 32) {
-            throw new IllegalArgumentException("(nShorts-1)*16+dstPos is greater or equal to than 32");
+            throw new IllegalArgumentException("(nShorts - 1) * 16 + dstPos >= 32");
         }
         int out = dstInit;
         for (int i = 0; i < nShorts; i++) {
@@ -1250,7 +1250,7 @@ public static int shortArrayToInt(final short[] src, final int srcPos, final int
      * @param nShorts the number of shorts to convert.
      * @return a long containing the selected bits.
      * @throws NullPointerException           if {@code src} is {@code null}.
-     * @throws IllegalArgumentException       if {@code (nShorts-1)*16+dstPos >= 64}.
+     * @throws IllegalArgumentException       if {@code (nShorts - 1) * 16 + dstPos >= 64}.
      * @throws ArrayIndexOutOfBoundsException if {@code srcPos + nShorts > src.length}.
      */
     public static long shortArrayToLong(final short[] src, final int srcPos, final long dstInit, final int dstPos, final int nShorts) {
@@ -1258,7 +1258,7 @@ public static long shortArrayToLong(final short[] src, final int srcPos, final l
             return dstInit;
         }
         if ((nShorts - 1) * 16 + dstPos >= 64) {
-            throw new IllegalArgumentException("(nShorts-1)*16+dstPos is greater or equal to than 64");
+            throw new IllegalArgumentException("(nShorts - 1) * 16 + dstPos >= 64");
         }
         long out = dstInit;
         for (int i = 0; i < nShorts; i++) {
@@ -1280,7 +1280,7 @@ public static long shortArrayToLong(final short[] src, final int srcPos, final l
      * @param nBools the number of booleans to copy to {@code dst}, must be smaller or equal to the width of the input (from srcPos to MSB).
      * @return {@code dst}.
      * @throws NullPointerException           if {@code dst} is {@code null}.
-     * @throws IllegalArgumentException       if {@code nBools-1+srcPos >= 16}.
+     * @throws IllegalArgumentException       if {@code nBools -  1 + srcPos >= 16}.
      * @throws ArrayIndexOutOfBoundsException if {@code dstPos + nBools > dst.length}.
      */
     public static boolean[] shortToBinary(final short src, final int srcPos, final boolean[] dst, final int dstPos, final int nBools) {
@@ -1288,7 +1288,7 @@ public static boolean[] shortToBinary(final short src, final int srcPos, final b
             return dst;
         }
         if (nBools - 1 + srcPos >= 16) {
-            throw new IllegalArgumentException("nBools-1+srcPos is greater or equal to than 16");
+            throw new IllegalArgumentException("nBools -  1 + srcPos >= 16");
         }
         assert nBools - 1 < 16 - srcPos;
         for (int i = 0; i < nBools; i++) {
@@ -1308,7 +1308,7 @@ public static boolean[] shortToBinary(final short src, final int srcPos, final b
      * @param nBytes the number of bytes to copy to {@code dst}, must be smaller or equal to the width of the input (from srcPos to MSB).
      * @return {@code dst}.
      * @throws NullPointerException           if {@code dst} is {@code null}.
-     * @throws IllegalArgumentException       if {@code (nBytes-1)*8+srcPos >= 16}.
+     * @throws IllegalArgumentException       if {@code (nBytes - 1) * 8 + srcPos >= 16}.
      * @throws ArrayIndexOutOfBoundsException if {@code dstPos + nBytes > dst.length}.
      */
     public static byte[] shortToByteArray(final short src, final int srcPos, final byte[] dst, final int dstPos, final int nBytes) {
@@ -1316,7 +1316,7 @@ public static byte[] shortToByteArray(final short src, final int srcPos, final b
             return dst;
         }
         if ((nBytes - 1) * 8 + srcPos >= 16) {
-            throw new IllegalArgumentException("(nBytes-1)*8+srcPos is greater or equal to than 16");
+            throw new IllegalArgumentException("(nBytes - 1) * 8 + srcPos >= 16");
         }
         for (int i = 0; i < nBytes; i++) {
             final int shift = i * 8 + srcPos;
@@ -1334,7 +1334,7 @@ public static byte[] shortToByteArray(final short src, final int srcPos, final b
      * @param dstPos  the position in {@code dst} where to copy the result.
      * @param nHexs   the number of chars to copy to {@code dst}, must be smaller or equal to the width of the input (from srcPos to MSB).
      * @return {@code dst}.
-     * @throws IllegalArgumentException        if {@code (nHexs-1)*4+srcPos >= 16}.
+     * @throws IllegalArgumentException        if {@code (nHexs - 1) * 4 + srcPos >= 16}.
      * @throws StringIndexOutOfBoundsException if {@code dst.init.length() < dstPos}.
      */
     public static String shortToHex(final short src, final int srcPos, final String dstInit, final int dstPos, final int nHexs) {
@@ -1342,7 +1342,7 @@ public static String shortToHex(final short src, final int srcPos, final String
             return dstInit;
         }
         if ((nHexs - 1) * 4 + srcPos >= 16) {
-            throw new IllegalArgumentException("(nHexs-1)*4+srcPos is greater or equal to than 16");
+            throw new IllegalArgumentException("(nHexs - 1) * 4 + srcPos >= 16");
         }
         final StringBuilder sb = new StringBuilder(dstInit);
         int append = sb.length();
@@ -1376,7 +1376,7 @@ public static byte[] uuidToByteArray(final UUID src, final byte[] dst, final int
             return dst;
         }
         if (nBytes > 16) {
-            throw new IllegalArgumentException("nBytes is greater than 16");
+            throw new IllegalArgumentException("nBytes > 16");
         }
         longToByteArray(src.getMostSignificantBits(), 0, dst, dstPos, Math.min(nBytes, 8));
         if (nBytes >= 8) {
diff --git a/src/test/java/org/apache/commons/lang3/ConversionTest.java b/src/test/java/org/apache/commons/lang3/ConversionTest.java
index 5d9682903..c0a4d3201 100644
--- a/src/test/java/org/apache/commons/lang3/ConversionTest.java
+++ b/src/test/java/org/apache/commons/lang3/ConversionTest.java
@@ -49,10 +49,9 @@ static String dbgPrint(final boolean[] src) {
     }
 
     @ParameterizedTest
-    @ValueSource(ints = {-1, 8, 99})
+    @ValueSource(ints = {Integer.MIN_VALUE -1, 8, 9, Integer.MAX_VALUE})
     public void binaryBeMsb0ToHexDigitPosOutsideArray(final int index) {
-        assertIndexOutOfBoundsException(
-            () -> Conversion.binaryBeMsb0ToHexDigit(new boolean[8], index));
+        assertIndexOutOfBoundsException(() -> Conversion.binaryBeMsb0ToHexDigit(new boolean[8], index));
     }
 
     /**
@@ -60,44 +59,25 @@ public void binaryBeMsb0ToHexDigitPosOutsideArray(final int index) {
      */
     @Test
     void testBinaryBeMsb0ToHexDigit() {
-        assertEquals(
-            '0', Conversion.binaryBeMsb0ToHexDigit(new boolean[]{false, false, false, false}));
-        assertEquals(
-            '1', Conversion.binaryBeMsb0ToHexDigit(new boolean[]{false, false, false, true}));
-        assertEquals(
-            '2', Conversion.binaryBeMsb0ToHexDigit(new boolean[]{false, false, true, false}));
-        assertEquals(
-            '3', Conversion.binaryBeMsb0ToHexDigit(new boolean[]{false, false, true, true}));
-        assertEquals(
-            '4', Conversion.binaryBeMsb0ToHexDigit(new boolean[]{false, true, false, false}));
-        assertEquals(
-            '5', Conversion.binaryBeMsb0ToHexDigit(new boolean[]{false, true, false, true}));
-        assertEquals(
-            '6', Conversion.binaryBeMsb0ToHexDigit(new boolean[]{false, true, true, false}));
-        assertEquals(
-            '7', Conversion.binaryBeMsb0ToHexDigit(new boolean[]{false, true, true, true}));
-        assertEquals(
-            '8', Conversion.binaryBeMsb0ToHexDigit(new boolean[]{true, false, false, false}));
-        assertEquals(
-            '9', Conversion.binaryBeMsb0ToHexDigit(new boolean[]{true, false, false, true}));
-        assertEquals(
-            'a', Conversion.binaryBeMsb0ToHexDigit(new boolean[]{true, false, true, false}));
-        assertEquals(
-            'b', Conversion.binaryBeMsb0ToHexDigit(new boolean[]{true, false, true, true}));
-        assertEquals(
-            'c', Conversion.binaryBeMsb0ToHexDigit(new boolean[]{true, true, false, false}));
-        assertEquals(
-            'd', Conversion.binaryBeMsb0ToHexDigit(new boolean[]{true, true, false, true}));
-        assertEquals(
-            'e', Conversion.binaryBeMsb0ToHexDigit(new boolean[]{true, true, true, false}));
-        assertEquals(
-            'f', Conversion.binaryBeMsb0ToHexDigit(new boolean[]{true, true, true, true}));
-        assertEquals(
-            '4',
-            Conversion.binaryBeMsb0ToHexDigit(new boolean[]{
-                true, false, false, false, false, false, false, false, false, false, false,
-                false, false, true, false, false}));
-        assertIllegalArgumentException(() -> Conversion.binaryBeMsb0ToHexDigit(new boolean[]{}));
+        assertEquals('0', Conversion.binaryBeMsb0ToHexDigit(new boolean[] { false, false, false, false }));
+        assertEquals('1', Conversion.binaryBeMsb0ToHexDigit(new boolean[] { false, false, false, true }));
+        assertEquals('2', Conversion.binaryBeMsb0ToHexDigit(new boolean[] { false, false, true, false }));
+        assertEquals('3', Conversion.binaryBeMsb0ToHexDigit(new boolean[] { false, false, true, true }));
+        assertEquals('4', Conversion.binaryBeMsb0ToHexDigit(new boolean[] { false, true, false, false }));
+        assertEquals('5', Conversion.binaryBeMsb0ToHexDigit(new boolean[] { false, true, false, true }));
+        assertEquals('6', Conversion.binaryBeMsb0ToHexDigit(new boolean[] { false, true, true, false }));
+        assertEquals('7', Conversion.binaryBeMsb0ToHexDigit(new boolean[] { false, true, true, true }));
+        assertEquals('8', Conversion.binaryBeMsb0ToHexDigit(new boolean[] { true, false, false, false }));
+        assertEquals('9', Conversion.binaryBeMsb0ToHexDigit(new boolean[] { true, false, false, true }));
+        assertEquals('a', Conversion.binaryBeMsb0ToHexDigit(new boolean[] { true, false, true, false }));
+        assertEquals('b', Conversion.binaryBeMsb0ToHexDigit(new boolean[] { true, false, true, true }));
+        assertEquals('c', Conversion.binaryBeMsb0ToHexDigit(new boolean[] { true, true, false, false }));
+        assertEquals('d', Conversion.binaryBeMsb0ToHexDigit(new boolean[] { true, true, false, true }));
+        assertEquals('e', Conversion.binaryBeMsb0ToHexDigit(new boolean[] { true, true, true, false }));
+        assertEquals('f', Conversion.binaryBeMsb0ToHexDigit(new boolean[] { true, true, true, true }));
+        assertEquals('4', Conversion.binaryBeMsb0ToHexDigit(
+                new boolean[] { true, false, false, false, false, false, false, false, false, false, false, false, false, true, false, false }));
+        assertIllegalArgumentException(() -> Conversion.binaryBeMsb0ToHexDigit(new boolean[] {}));
     }
 
     /**


(commons-lang) 01/06: Revert to the released behavior and update tests

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-lang.git

commit ae8ba316cfaa3102e1ea7067646c0f107d1b30ca
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Wed Sep 3 07:51:08 2025 -0400

    Revert to the released behavior and update tests
---
 .../java/org/apache/commons/lang3/Conversion.java  | 43 +++++++---------------
 .../org/apache/commons/lang3/ConversionTest.java   | 24 ++++++------
 2 files changed, 26 insertions(+), 41 deletions(-)

diff --git a/src/main/java/org/apache/commons/lang3/Conversion.java b/src/main/java/org/apache/commons/lang3/Conversion.java
index feec25270..7febe1a87 100644
--- a/src/main/java/org/apache/commons/lang3/Conversion.java
+++ b/src/main/java/org/apache/commons/lang3/Conversion.java
@@ -778,13 +778,14 @@ public static int hexDigitToInt(final char hexDigit) {
     /**
      * Converts a hexadecimal string into a byte using the default (little-endian, Lsb0) byte and bit ordering.
      *
-     * @param src     the hexadecimal string to convert.
-     * @param srcPos  the position in {@code src}, in char unit, from where to start the conversion.
-     * @param dstInit initial value of the destination byte.
-     * @param dstPos  the position of the LSB, in bits, in the result byte.
-     * @param nHex    the number of chars to convert.
-     * @return a byte containing the selected bits.
-     * @throws IllegalArgumentException Thrown on invalid input like {@code (nHex - 1) * 4 + dstPos >= 8}.
+     * @param src the hexadecimal string to convert
+     * @param srcPos the position in {@code src}, in Char unit, from where to start the
+     *            conversion
+     * @param dstInit initial value of the destination byte
+     * @param dstPos the position of the LSB, in bits, in the result byte
+     * @param nHex the number of Chars to convert
+     * @return a byte containing the selected bits
+     * @throws IllegalArgumentException if {@code (nHex-1)*4+dstPos >= 8}
      */
     public static byte hexToByte(final String src, final int srcPos, final byte dstInit, final int dstPos, final int nHex) {
         if (0 == nHex) {
@@ -793,10 +794,6 @@ public static byte hexToByte(final String src, final int srcPos, final byte dstI
         if ((nHex - 1) * 4 + dstPos >= 8) {
             throw new IllegalArgumentException("(nHex - 1) * 4 + dstPos is greater than or equal to 8");
         }
-        if (srcPos < 0 || nHex < 0 || srcPos > src.length() - nHex) {
-            throw new IllegalArgumentException(
-                    String.format("srcPos %,d, dstInit %,d, dstPos %,d, nHex %,d, src.length() %,d", srcPos, dstInit, dstPos, nHex, src.length()));
-        }
         byte out = dstInit;
         for (int i = 0; i < nHex; i++) {
             final int shift = i * 4 + dstPos;
@@ -818,18 +815,14 @@ public static byte hexToByte(final String src, final int srcPos, final byte dstI
      * @param dstPos the position of the LSB, in bits, in the result int
      * @param nHex the number of chars to convert
      * @return an int containing the selected bits
-     * @throws IllegalArgumentException Thrown on invalid input like {@code (nHex - 1) * 4 + dstPos >= 32}
+     * @throws IllegalArgumentException if {@code (nHexs-1)*4+dstPos >= 32}
      */
     public static int hexToInt(final String src, final int srcPos, final int dstInit, final int dstPos, final int nHex) {
         if (0 == nHex) {
             return dstInit;
         }
         if ((nHex - 1) * 4 + dstPos >= 32) {
-            throw new IllegalArgumentException("(nHex - 1) * 4 + dstPos is greater or equal to than 32");
-        }
-        if (srcPos < 0 || nHex < 0 || srcPos > src.length() - nHex) {
-            throw new IllegalArgumentException(
-                    String.format("srcPos %,d, dstInit %,d, dstPos %,d, nHex %,d, src.length() %,d", srcPos, dstInit, dstPos, nHex, src.length()));
+            throw new IllegalArgumentException("(nHexs-1)*4+dstPos is greater or equal to than 32");
         }
         int out = dstInit;
         for (int i = 0; i < nHex; i++) {
@@ -852,18 +845,14 @@ public static int hexToInt(final String src, final int srcPos, final int dstInit
      * @param dstPos the position of the LSB, in bits, in the result long
      * @param nHex the number of chars to convert
      * @return a long containing the selected bits
-     * @throws IllegalArgumentException Thrown on invalid input like {@code (nHex - 1) * 4 + dstPos >= 64}
+     * @throws IllegalArgumentException if {@code (nHexs-1)*4+dstPos >= 64}
      */
     public static long hexToLong(final String src, final int srcPos, final long dstInit, final int dstPos, final int nHex) {
         if (0 == nHex) {
             return dstInit;
         }
         if ((nHex - 1) * 4 + dstPos >= 64) {
-            throw new IllegalArgumentException("(nHex - 1) * 4 + dstPos is greater or equal to than 64");
-        }
-        if (srcPos < 0 || nHex < 0 || srcPos > src.length() - nHex) {
-            throw new IllegalArgumentException(
-                    String.format("srcPos %,d, dstInit %,d, dstPos %,d, nHex %,d, src.length() %,d", srcPos, dstInit, dstPos, nHex, src.length()));
+            throw new IllegalArgumentException("(nHexs-1)*4+dstPos is greater or equal to than 64");
         }
         long out = dstInit;
         for (int i = 0; i < nHex; i++) {
@@ -886,18 +875,14 @@ public static long hexToLong(final String src, final int srcPos, final long dstI
      * @param dstPos the position of the LSB, in bits, in the result short
      * @param nHex the number of chars to convert
      * @return a short containing the selected bits
-     * @throws IllegalArgumentException Thrown on invalid input like {@code (nHex - 1) * 4 + dstPos >= 16}
+     * @throws IllegalArgumentException if {@code (nHexs-1)*4+dstPos >= 16}
      */
     public static short hexToShort(final String src, final int srcPos, final short dstInit, final int dstPos, final int nHex) {
         if (0 == nHex) {
             return dstInit;
         }
         if ((nHex - 1) * 4 + dstPos >= 16) {
-            throw new IllegalArgumentException("(nHex - 1) * 4 + dstPos is greater or equal to than 16");
-        }
-        if (srcPos < 0 || nHex < 0 || srcPos > src.length() - nHex) {
-            throw new IllegalArgumentException(
-                    String.format("srcPos %,d, dstInit %,d, dstPos %,d, nHex %,d, src.length() %,d", srcPos, dstInit, dstPos, nHex, src.length()));
+            throw new IllegalArgumentException("(nHexs-1)*4+dstPos is greater or equal to than 16");
         }
         short out = dstInit;
         for (int i = 0; i < nHex; i++) {
diff --git a/src/test/java/org/apache/commons/lang3/ConversionTest.java b/src/test/java/org/apache/commons/lang3/ConversionTest.java
index 75d6a34a0..5d9682903 100644
--- a/src/test/java/org/apache/commons/lang3/ConversionTest.java
+++ b/src/test/java/org/apache/commons/lang3/ConversionTest.java
@@ -708,9 +708,9 @@ void testHexToByte() {
         assertEquals((byte) 0xFD, Conversion.hexToByte(src, 1, (byte) 0, 0, 2));
         assertEquals((byte) 0x34, Conversion.hexToByte(src, 0, (byte) 0x34, 0, 0));
         assertEquals((byte) 0x84, Conversion.hexToByte(src, 17, (byte) 0x34, 4, 1));
-        assertThrows(IllegalArgumentException.class, () -> Conversion.hexToByte(src, src.length(), (byte) 0, 0, 1));
-        assertThrows(IllegalArgumentException.class, () -> Conversion.hexToByte(src, Integer.MIN_VALUE, (byte) 0, 0, 1));
-        assertThrows(IllegalArgumentException.class, () -> Conversion.hexToByte(src, Integer.MAX_VALUE, (byte) 0, 0, 1));
+        assertThrows(StringIndexOutOfBoundsException.class, () -> Conversion.hexToByte(src, src.length(), (byte) 0, 0, 1));
+        assertThrows(StringIndexOutOfBoundsException.class, () -> Conversion.hexToByte(src, Integer.MIN_VALUE, (byte) 0, 0, 1));
+        assertThrows(StringIndexOutOfBoundsException.class, () -> Conversion.hexToByte(src, Integer.MAX_VALUE, (byte) 0, 0, 1));
     }
 
     /**
@@ -725,9 +725,9 @@ void testHexToInt() {
         assertEquals(0x01C0F1FD, Conversion.hexToInt(src, 1, 0, 0, 8));
         assertEquals(0x12345679, Conversion.hexToInt(src, 0, 0x12345679, 0, 0));
         assertEquals(0x87645679, Conversion.hexToInt(src, 15, 0x12345679, 20, 3));
-        assertThrows(IllegalArgumentException.class, () -> Conversion.hexToInt(src, src.length(), 0, 0, 1));
-        assertThrows(IllegalArgumentException.class, () -> Conversion.hexToInt(src, Integer.MIN_VALUE, 0, 0, 1));
-        assertThrows(IllegalArgumentException.class, () -> Conversion.hexToInt(src, Integer.MAX_VALUE, 0, 0, 1));
+        assertThrows(StringIndexOutOfBoundsException.class, () -> Conversion.hexToInt(src, src.length(), 0, 0, 1));
+        assertThrows(StringIndexOutOfBoundsException.class, () -> Conversion.hexToInt(src, Integer.MIN_VALUE, 0, 0, 1));
+        assertThrows(StringIndexOutOfBoundsException.class, () -> Conversion.hexToInt(src, Integer.MAX_VALUE, 0, 0, 1));
     }
 
     /**
@@ -742,9 +742,9 @@ void testHexToLong() {
         assertEquals(0x0000000001C0F1FDL, Conversion.hexToLong(src, 1, 0L, 0, 8));
         assertEquals(0x123456798ABCDEF0L, Conversion.hexToLong(src, 0, 0x123456798ABCDEF0L, 0, 0));
         assertEquals(0x1234567876BCDEF0L, Conversion.hexToLong(src, 15, 0x123456798ABCDEF0L, 24, 3));
-        assertThrows(IllegalArgumentException.class, () -> Conversion.hexToLong(src, src.length(), 0, 0, 1));
-        assertThrows(IllegalArgumentException.class, () -> Conversion.hexToLong(src, Integer.MIN_VALUE, 0, 0, 1));
-        assertThrows(IllegalArgumentException.class, () -> Conversion.hexToLong(src, Integer.MAX_VALUE, 0, 0, 1));
+        assertThrows(StringIndexOutOfBoundsException.class, () -> Conversion.hexToLong(src, src.length(), 0, 0, 1));
+        assertThrows(StringIndexOutOfBoundsException.class, () -> Conversion.hexToLong(src, Integer.MIN_VALUE, 0, 0, 1));
+        assertThrows(StringIndexOutOfBoundsException.class, () -> Conversion.hexToLong(src, Integer.MAX_VALUE, 0, 0, 1));
     }
 
     /**
@@ -759,9 +759,9 @@ void testHexToShort() {
         assertEquals((short) 0xF1FD, Conversion.hexToShort(src, 1, (short) 0, 0, 4));
         assertEquals((short) 0x1234, Conversion.hexToShort(src, 0, (short) 0x1234, 0, 0));
         assertEquals((short) 0x8764, Conversion.hexToShort(src, 15, (short) 0x1234, 4, 3));
-        assertThrows(IllegalArgumentException.class, () -> Conversion.hexToShort(src, src.length(), (short) 0, 0, 1));
-        assertThrows(IllegalArgumentException.class, () -> Conversion.hexToShort(src, Integer.MIN_VALUE, (short) 0, 0, 1));
-        assertThrows(IllegalArgumentException.class, () -> Conversion.hexToShort(src, Integer.MAX_VALUE, (short) 0, 0, 1));
+        assertThrows(StringIndexOutOfBoundsException.class, () -> Conversion.hexToShort(src, src.length(), (short) 0, 0, 1));
+        assertThrows(StringIndexOutOfBoundsException.class, () -> Conversion.hexToShort(src, Integer.MIN_VALUE, (short) 0, 0, 1));
+        assertThrows(StringIndexOutOfBoundsException.class, () -> Conversion.hexToShort(src, Integer.MAX_VALUE, (short) 0, 0, 1));
     }
 
     /**


(commons-lang) 02/06: Comments

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-lang.git

commit b284082bf1d1a9664abf3b6f772a7eaa9608585c
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Wed Sep 3 07:53:28 2025 -0400

    Comments
---
 .../java/org/apache/commons/lang3/Conversion.java  | 64 ++++++++++------------
 1 file changed, 30 insertions(+), 34 deletions(-)

diff --git a/src/main/java/org/apache/commons/lang3/Conversion.java b/src/main/java/org/apache/commons/lang3/Conversion.java
index 7febe1a87..aff2e7a19 100644
--- a/src/main/java/org/apache/commons/lang3/Conversion.java
+++ b/src/main/java/org/apache/commons/lang3/Conversion.java
@@ -83,13 +83,13 @@ public class Conversion {
      *
      * <p>
      * (1, 0, 0, 0) is converted as follow: '8' (1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0) is converted
-     * to '4'
+     * to '4'.
      * </p>
      *
-     * @param src the binary to convert
-     * @return a hexadecimal digit representing the selected bits
-     * @throws IllegalArgumentException if {@code src} is empty
-     * @throws NullPointerException if {@code src} is {@code null}
+     * @param src the binary to convert.
+     * @return a hexadecimal digit representing the selected bits.
+     * @throws IllegalArgumentException if {@code src} is empty.
+     * @throws NullPointerException if {@code src} is {@code null}.
      */
     public static char binaryBeMsb0ToHexDigit(final boolean[] src) {
         return binaryBeMsb0ToHexDigit(src, 0);
@@ -101,14 +101,14 @@ public static char binaryBeMsb0ToHexDigit(final boolean[] src) {
      *
      * <p>
      * (1, 0, 0, 0) with srcPos = 0 is converted as follow: '8' (1, 0, 0, 0, 0, 0, 0, 0,
-     * 0, 0, 0, 1, 0, 1, 0, 0) with srcPos = 2 is converted to '5'
+     * 0, 0, 0, 1, 0, 1, 0, 0) with srcPos = 2 is converted to '5'.
      * </p>
      *
-     * @param src the binary to convert
-     * @param srcPos the position of the LSB to start the conversion
-     * @return a hexadecimal digit representing the selected bits
-     * @throws IllegalArgumentException if {@code src} is empty
-     * @throws NullPointerException if {@code src} is {@code null}
+     * @param src the binary to convert.
+     * @param srcPos the position of the LSB to start the conversion.
+     * @return a hexadecimal digit representing the selected bits.
+     * @throws IllegalArgumentException if {@code src} is empty.
+     * @throws NullPointerException if {@code src} is {@code null}.
      * @throws IndexOutOfBoundsException if {@code srcPos} is outside the array.
      */
     public static char binaryBeMsb0ToHexDigit(final boolean[] src, final int srcPos) {
@@ -147,19 +147,17 @@ public static char binaryBeMsb0ToHexDigit(final boolean[] src, final int srcPos)
     }
 
     /**
-     * Converts binary (represented as boolean array) into a byte using the default (little
-     * endian, Lsb0) byte and bit ordering.
+     * Converts binary (represented as boolean array) into a byte using the default (little endian, Lsb0) byte and bit ordering.
      *
-     * @param src the binary to convert
-     * @param srcPos the position in {@code src}, in boolean unit, from where to start the
-     *            conversion
-     * @param dstInit initial value of the destination byte
-     * @param dstPos the position of the LSB, in bits, in the result byte
-     * @param nBools the number of booleans to convert
-     * @return a byte containing the selected bits
-     * @throws NullPointerException if {@code src} is {@code null}
-     * @throws IllegalArgumentException if {@code nBools-1+dstPos >= 8}
-     * @throws ArrayIndexOutOfBoundsException if {@code srcPos + nBools > src.length}
+     * @param src     the binary to convert.
+     * @param srcPos  the position in {@code src}, in boolean unit, from where to start the conversion.
+     * @param dstInit initial value of the destination byte.
+     * @param dstPos  the position of the LSB, in bits, in the result byte.
+     * @param nBools  the number of booleans to convert.
+     * @return a byte containing the selected bits.
+     * @throws NullPointerException           if {@code src} is {@code null}.
+     * @throws IllegalArgumentException       if {@code nBools-1+dstPos >= 8}.
+     * @throws ArrayIndexOutOfBoundsException if {@code srcPos + nBools > src.length}.
      */
     public static byte binaryToByte(final boolean[] src, final int srcPos, final byte dstInit, final int dstPos,
             final int nBools) {
@@ -988,18 +986,16 @@ public static byte[] intToByteArray(final int src, final int srcPos, final byte[
     }
 
     /**
-     * Converts an int into an array of Char using the default (little-endian, Lsb0) byte and bit
-     * ordering.
+     * Converts an int into an array of Char using the default (little-endian, Lsb0) byte and bit ordering.
      *
-     * @param src the int to convert
-     * @param srcPos the position in {@code src}, in bits, from where to start the conversion
-     * @param dstInit the initial value for the result String
-     * @param dstPos the position in {@code dst} where to copy the result
-     * @param nHexs the number of chars to copy to {@code dst}, must be smaller or equal to the
-     *            width of the input (from srcPos to MSB)
-     * @return {@code dst}
-     * @throws IllegalArgumentException if {@code (nHexs-1)*4+srcPos >= 32}
-     * @throws StringIndexOutOfBoundsException if {@code dst.init.length() < dstPos}
+     * @param src     the int to convert.
+     * @param srcPos  the position in {@code src}, in bits, from where to start the conversion.
+     * @param dstInit the initial value for the result String.
+     * @param dstPos  the position in {@code dst} where to copy the result.
+     * @param nHexs   the number of chars to copy to {@code dst}, must be smaller or equal to the width of the input (from srcPos to MSB).
+     * @return {@code dst}.
+     * @throws IllegalArgumentException        if {@code (nHexs-1)*4+srcPos >= 32}.
+     * @throws StringIndexOutOfBoundsException if {@code dst.init.length() < dstPos}.
      */
     public static String intToHex(final int src, final int srcPos, final String dstInit, final int dstPos,
             final int nHexs) {


(commons-lang) 04/06: Improve Javadocs for Conversion

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-lang.git

commit 9456a9a3192cd7a726381f1816674d02b67ed129
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Wed Sep 3 08:02:05 2025 -0400

    Improve Javadocs for Conversion
---
 src/changes/changes.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index aa48d893e..85f089751 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -58,7 +58,7 @@ The <action> type attribute can be add,update,fix,remove.
     <action issue="LANG-1597" type="fix" dev="ggregory" due-to="Richard Eckart de Castilho, Gary Gregory">Invocation fails because matching varargs method found but then discarded.</action>
     <action                   type="fix" dev="ggregory" due-to="Gary Gregory">Don't check accessibility twice in MemberUtils.setAccessibleWorkaround(T).</action>
     <action issue="LANG-1774" type="fix" dev="ggregory" due-to="Zhongxin Yan, Madhur Lathi, Yudan Liu, Gary Gregory">Improve handling of ClassUtils.getShortCanonicalName() for invalid input #1437.</action>
-    <action issue="LANG-1720" type="fix" dev="ggregory" due-to="Sheung Chi Chan, Arthur Chan, Gary Gregory, Elliotte Rusty Harold">Conversion.hexTo*() methods now throw IllegalArgumentException instead of StringIndexOutOfBoundsException.</action>
+    <action issue="LANG-1720" type="fix" dev="ggregory" due-to="Sheung Chi Chan, Arthur Chan, Gary Gregory, Elliotte Rusty Harold">Improve Javadocs for Conversion.</action>
     <action                   type="fix" dev="ggregory" due-to="mayuming">Fix CalendarUtils.toLocalDate() Javadoc return type description #1440.</action>
     <!-- FIX Javadoc -->
     <action                   type="fix" dev="ggregory" due-to="Gary Gregory">[javadoc] General improvements.</action>


(commons-lang) 06/06: Use JRE constants

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-lang.git

commit 8a5ea521fd60990d6612a62f539a0ca6abdef54e
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Wed Sep 3 08:30:38 2025 -0400

    Use JRE constants
---
 .../java/org/apache/commons/lang3/Conversion.java  | 86 +++++++++++-----------
 .../org/apache/commons/lang3/ConversionTest.java   |  2 +-
 2 files changed, 44 insertions(+), 44 deletions(-)

diff --git a/src/main/java/org/apache/commons/lang3/Conversion.java b/src/main/java/org/apache/commons/lang3/Conversion.java
index 4f08eb5cf..876293477 100644
--- a/src/main/java/org/apache/commons/lang3/Conversion.java
+++ b/src/main/java/org/apache/commons/lang3/Conversion.java
@@ -156,7 +156,7 @@ public static byte binaryToByte(final boolean[] src, final int srcPos, final byt
         if (src.length == 0 && srcPos == 0 || 0 == nBools) {
             return dstInit;
         }
-        if (nBools - 1 + dstPos >= 8) {
+        if (nBools - 1 + dstPos >= Byte.SIZE) {
             throw new IllegalArgumentException("nBools - 1 + dstPos >= 8");
         }
         byte out = dstInit;
@@ -256,7 +256,7 @@ public static char binaryToHexDigitMsb0_4bits(final boolean[] src) {
      * @throws NullPointerException     if {@code src} is {@code null}.
      */
     public static char binaryToHexDigitMsb0_4bits(final boolean[] src, final int srcPos) {
-        if (src.length > 8) {
+        if (src.length > Byte.SIZE) {
             throw new IllegalArgumentException("src.length > 8: src.length=" + src.length);
         }
         if (src.length - srcPos < 4) {
@@ -303,7 +303,7 @@ public static int binaryToInt(final boolean[] src, final int srcPos, final int d
         if (src.length == 0 && srcPos == 0 || 0 == nBools) {
             return dstInit;
         }
-        if (nBools - 1 + dstPos >= 32) {
+        if (nBools - 1 + dstPos >= Integer.SIZE) {
             throw new IllegalArgumentException("nBools - 1 + dstPos >= 32");
         }
         int out = dstInit;
@@ -333,7 +333,7 @@ public static long binaryToLong(final boolean[] src, final int srcPos, final lon
         if (src.length == 0 && srcPos == 0 || 0 == nBools) {
             return dstInit;
         }
-        if (nBools - 1 + dstPos >= 64) {
+        if (nBools - 1 + dstPos >= Long.SIZE) {
             throw new IllegalArgumentException("nBools - 1 + dstPos >= 64");
         }
         long out = dstInit;
@@ -363,7 +363,7 @@ public static short binaryToShort(final boolean[] src, final int srcPos, final s
         if (src.length == 0 && srcPos == 0 || 0 == nBools) {
             return dstInit;
         }
-        if (nBools - 1 + dstPos >= 16) {
+        if (nBools - 1 + dstPos >= Short.SIZE) {
             throw new IllegalArgumentException("nBools - 1 + dstPos >= 16");
         }
         short out = dstInit;
@@ -393,12 +393,12 @@ public static int byteArrayToInt(final byte[] src, final int srcPos, final int d
         if (src.length == 0 && srcPos == 0 || 0 == nBytes) {
             return dstInit;
         }
-        if ((nBytes - 1) * 8 + dstPos >= 32) {
+        if ((nBytes - 1) * Byte.SIZE + dstPos >= Integer.SIZE) {
             throw new IllegalArgumentException("(nBytes - 1) * 8 + dstPos >= 32");
         }
         int out = dstInit;
         for (int i = 0; i < nBytes; i++) {
-            final int shift = i * 8 + dstPos;
+            final int shift = i * Byte.SIZE + dstPos;
             final int bits = (0xff & src[i + srcPos]) << shift;
             final int mask = 0xff << shift;
             out = out & ~mask | bits;
@@ -423,12 +423,12 @@ public static long byteArrayToLong(final byte[] src, final int srcPos, final lon
         if (src.length == 0 && srcPos == 0 || 0 == nBytes) {
             return dstInit;
         }
-        if ((nBytes - 1) * 8 + dstPos >= 64) {
+        if ((nBytes - 1) * Byte.SIZE + dstPos >= Long.SIZE) {
             throw new IllegalArgumentException("(nBytes - 1) * 8 + dstPos >= 64");
         }
         long out = dstInit;
         for (int i = 0; i < nBytes; i++) {
-            final int shift = i * 8 + dstPos;
+            final int shift = i * Byte.SIZE + dstPos;
             final long bits = (0xffL & src[i + srcPos]) << shift;
             final long mask = 0xffL << shift;
             out = out & ~mask | bits;
@@ -453,12 +453,12 @@ public static short byteArrayToShort(final byte[] src, final int srcPos, final s
         if (src.length == 0 && srcPos == 0 || 0 == nBytes) {
             return dstInit;
         }
-        if ((nBytes - 1) * 8 + dstPos >= 16) {
+        if ((nBytes - 1) * Byte.SIZE + dstPos >= Short.SIZE) {
             throw new IllegalArgumentException("(nBytes - 1) * 8 + dstPos >= 16");
         }
         short out = dstInit;
         for (int i = 0; i < nBytes; i++) {
-            final int shift = i * 8 + dstPos;
+            final int shift = i * Byte.SIZE + dstPos;
             final int bits = (0xff & src[i + srcPos]) << shift;
             final int mask = 0xff << shift;
             out = (short) (out & ~mask | bits);
@@ -479,7 +479,7 @@ public static UUID byteArrayToUuid(final byte[] src, final int srcPos) {
         if (src.length - srcPos < 16) {
             throw new IllegalArgumentException("Need at least 16 bytes for UUID");
         }
-        return new UUID(byteArrayToLong(src, srcPos, 0, 0, 8), byteArrayToLong(src, srcPos + 8, 0, 0, 8));
+        return new UUID(byteArrayToLong(src, srcPos, 0, 0, Byte.SIZE), byteArrayToLong(src, srcPos + 8, 0, 0, Byte.SIZE));
     }
 
     /**
@@ -499,7 +499,7 @@ public static boolean[] byteToBinary(final byte src, final int srcPos, final boo
         if (0 == nBools) {
             return dst;
         }
-        if (nBools - 1 + srcPos >= 8) {
+        if (nBools - 1 + srcPos >= Byte.SIZE) {
             throw new IllegalArgumentException("nBools -  1 + srcPos >= 8");
         }
         for (int i = 0; i < nBools; i++) {
@@ -525,7 +525,7 @@ public static String byteToHex(final byte src, final int srcPos, final String ds
         if (0 == nHexs) {
             return dstInit;
         }
-        if ((nHexs - 1) * 4 + srcPos >= 8) {
+        if ((nHexs - 1) * 4 + srcPos >= Byte.SIZE) {
             throw new IllegalArgumentException("(nHexs - 1) * 4 + srcPos >= 8");
         }
         final StringBuilder sb = new StringBuilder(dstInit);
@@ -745,7 +745,7 @@ public static byte hexToByte(final String src, final int srcPos, final byte dstI
         if (0 == nHex) {
             return dstInit;
         }
-        if ((nHex - 1) * 4 + dstPos >= 8) {
+        if ((nHex - 1) * 4 + dstPos >= Byte.SIZE) {
             throw new IllegalArgumentException("(nHex - 1) * 4 + dstPos >= 8");
         }
         byte out = dstInit;
@@ -773,7 +773,7 @@ public static int hexToInt(final String src, final int srcPos, final int dstInit
         if (0 == nHex) {
             return dstInit;
         }
-        if ((nHex - 1) * 4 + dstPos >= 32) {
+        if ((nHex - 1) * 4 + dstPos >= Integer.SIZE) {
             throw new IllegalArgumentException("(nHexs - 1) * 4 + dstPos >= 32");
         }
         int out = dstInit;
@@ -801,7 +801,7 @@ public static long hexToLong(final String src, final int srcPos, final long dstI
         if (0 == nHex) {
             return dstInit;
         }
-        if ((nHex - 1) * 4 + dstPos >= 64) {
+        if ((nHex - 1) * 4 + dstPos >= Long.SIZE) {
             throw new IllegalArgumentException("(nHexs - 1) * 4 + dstPos >= 64");
         }
         long out = dstInit;
@@ -829,7 +829,7 @@ public static short hexToShort(final String src, final int srcPos, final short d
         if (0 == nHex) {
             return dstInit;
         }
-        if ((nHex - 1) * 4 + dstPos >= 16) {
+        if ((nHex - 1) * 4 + dstPos >= Short.SIZE) {
             throw new IllegalArgumentException("(nHexs - 1) * 4 + dstPos >= 16");
         }
         short out = dstInit;
@@ -859,12 +859,12 @@ public static long intArrayToLong(final int[] src, final int srcPos, final long
         if (src.length == 0 && srcPos == 0 || 0 == nInts) {
             return dstInit;
         }
-        if ((nInts - 1) * 32 + dstPos >= 64) {
+        if ((nInts - 1) * Integer.SIZE + dstPos >= Long.SIZE) {
             throw new IllegalArgumentException("(nInts - 1) * 32 + dstPos >= 64");
         }
         long out = dstInit;
         for (int i = 0; i < nInts; i++) {
-            final int shift = i * 32 + dstPos;
+            final int shift = i * Integer.SIZE + dstPos;
             final long bits = (0xffffffffL & src[i + srcPos]) << shift;
             final long mask = 0xffffffffL << shift;
             out = out & ~mask | bits;
@@ -889,7 +889,7 @@ public static boolean[] intToBinary(final int src, final int srcPos, final boole
         if (0 == nBools) {
             return dst;
         }
-        if (nBools - 1 + srcPos >= 32) {
+        if (nBools - 1 + srcPos >= Integer.SIZE) {
             throw new IllegalArgumentException("nBools -  1 + srcPos >= 32");
         }
         for (int i = 0; i < nBools; i++) {
@@ -916,11 +916,11 @@ public static byte[] intToByteArray(final int src, final int srcPos, final byte[
         if (0 == nBytes) {
             return dst;
         }
-        if ((nBytes - 1) * 8 + srcPos >= 32) {
+        if ((nBytes - 1) * Byte.SIZE + srcPos >= Integer.SIZE) {
             throw new IllegalArgumentException("(nBytes - 1) * 8 + srcPos >= 32");
         }
         for (int i = 0; i < nBytes; i++) {
-            final int shift = i * 8 + srcPos;
+            final int shift = i * Byte.SIZE + srcPos;
             dst[dstPos + i] = (byte) (0xff & src >> shift);
         }
         return dst;
@@ -942,7 +942,7 @@ public static String intToHex(final int src, final int srcPos, final String dstI
         if (0 == nHexs) {
             return dstInit;
         }
-        if ((nHexs - 1) * 4 + srcPos >= 32) {
+        if ((nHexs - 1) * 4 + srcPos >= Integer.SIZE) {
             throw new IllegalArgumentException("(nHexs - 1) * 4 + srcPos >= 32");
         }
         final StringBuilder sb = new StringBuilder(dstInit);
@@ -1058,11 +1058,11 @@ public static short[] intToShortArray(final int src, final int srcPos, final sho
         if (0 == nShorts) {
             return dst;
         }
-        if ((nShorts - 1) * 16 + srcPos >= 32) {
+        if ((nShorts - 1) * Short.SIZE + srcPos >= Integer.SIZE) {
             throw new IllegalArgumentException("(nShorts - 1) * 16 + srcPos >= 32");
         }
         for (int i = 0; i < nShorts; i++) {
-            final int shift = i * 16 + srcPos;
+            final int shift = i * Short.SIZE + srcPos;
             dst[dstPos + i] = (short) (0xffff & src >> shift);
         }
         return dst;
@@ -1085,7 +1085,7 @@ public static boolean[] longToBinary(final long src, final int srcPos, final boo
         if (0 == nBools) {
             return dst;
         }
-        if (nBools - 1 + srcPos >= 64) {
+        if (nBools - 1 + srcPos >= Long.SIZE) {
             throw new IllegalArgumentException("nBools -  1 + srcPos >= 64");
         }
         for (int i = 0; i < nBools; i++) {
@@ -1112,11 +1112,11 @@ public static byte[] longToByteArray(final long src, final int srcPos, final byt
         if (0 == nBytes) {
             return dst;
         }
-        if ((nBytes - 1) * 8 + srcPos >= 64) {
+        if ((nBytes - 1) * Byte.SIZE + srcPos >= Long.SIZE) {
             throw new IllegalArgumentException("(nBytes - 1) * 8 + srcPos >= 64");
         }
         for (int i = 0; i < nBytes; i++) {
-            final int shift = i * 8 + srcPos;
+            final int shift = i * Byte.SIZE + srcPos;
             dst[dstPos + i] = (byte) (0xff & src >> shift);
         }
         return dst;
@@ -1138,7 +1138,7 @@ public static String longToHex(final long src, final int srcPos, final String ds
         if (0 == nHexs) {
             return dstInit;
         }
-        if ((nHexs - 1) * 4 + srcPos >= 64) {
+        if ((nHexs - 1) * 4 + srcPos >= Long.SIZE) {
             throw new IllegalArgumentException("(nHexs - 1) * 4 + srcPos >= 64");
         }
         final StringBuilder sb = new StringBuilder(dstInit);
@@ -1173,11 +1173,11 @@ public static int[] longToIntArray(final long src, final int srcPos, final int[]
         if (0 == nInts) {
             return dst;
         }
-        if ((nInts - 1) * 32 + srcPos >= 64) {
+        if ((nInts - 1) * Integer.SIZE + srcPos >= Long.SIZE) {
             throw new IllegalArgumentException("(nInts - 1) * 32 + srcPos >= 64");
         }
         for (int i = 0; i < nInts; i++) {
-            final int shift = i * 32 + srcPos;
+            final int shift = i * Integer.SIZE + srcPos;
             dst[dstPos + i] = (int) (0xffffffff & src >> shift);
         }
         return dst;
@@ -1200,11 +1200,11 @@ public static short[] longToShortArray(final long src, final int srcPos, final s
         if (0 == nShorts) {
             return dst;
         }
-        if ((nShorts - 1) * 16 + srcPos >= 64) {
+        if ((nShorts - 1) * Short.SIZE + srcPos >= Long.SIZE) {
             throw new IllegalArgumentException("(nShorts - 1) * 16 + srcPos >= 64");
         }
         for (int i = 0; i < nShorts; i++) {
-            final int shift = i * 16 + srcPos;
+            final int shift = i * Short.SIZE + srcPos;
             dst[dstPos + i] = (short) (0xffff & src >> shift);
         }
         return dst;
@@ -1227,12 +1227,12 @@ public static int shortArrayToInt(final short[] src, final int srcPos, final int
         if (src.length == 0 && srcPos == 0 || 0 == nShorts) {
             return dstInit;
         }
-        if ((nShorts - 1) * 16 + dstPos >= 32) {
+        if ((nShorts - 1) * Short.SIZE + dstPos >= Integer.SIZE) {
             throw new IllegalArgumentException("(nShorts - 1) * 16 + dstPos >= 32");
         }
         int out = dstInit;
         for (int i = 0; i < nShorts; i++) {
-            final int shift = i * 16 + dstPos;
+            final int shift = i * Short.SIZE + dstPos;
             final int bits = (0xffff & src[i + srcPos]) << shift;
             final int mask = 0xffff << shift;
             out = out & ~mask | bits;
@@ -1257,12 +1257,12 @@ public static long shortArrayToLong(final short[] src, final int srcPos, final l
         if (src.length == 0 && srcPos == 0 || 0 == nShorts) {
             return dstInit;
         }
-        if ((nShorts - 1) * 16 + dstPos >= 64) {
+        if ((nShorts - 1) * Short.SIZE + dstPos >= Long.SIZE) {
             throw new IllegalArgumentException("(nShorts - 1) * 16 + dstPos >= 64");
         }
         long out = dstInit;
         for (int i = 0; i < nShorts; i++) {
-            final int shift = i * 16 + dstPos;
+            final int shift = i * Short.SIZE + dstPos;
             final long bits = (0xffffL & src[i + srcPos]) << shift;
             final long mask = 0xffffL << shift;
             out = out & ~mask | bits;
@@ -1287,10 +1287,10 @@ public static boolean[] shortToBinary(final short src, final int srcPos, final b
         if (0 == nBools) {
             return dst;
         }
-        if (nBools - 1 + srcPos >= 16) {
+        if (nBools - 1 + srcPos >= Short.SIZE) {
             throw new IllegalArgumentException("nBools -  1 + srcPos >= 16");
         }
-        assert nBools - 1 < 16 - srcPos;
+        assert nBools - 1 < Short.SIZE - srcPos;
         for (int i = 0; i < nBools; i++) {
             final int shift = i + srcPos;
             dst[dstPos + i] = (0x1 & src >> shift) != 0;
@@ -1315,11 +1315,11 @@ public static byte[] shortToByteArray(final short src, final int srcPos, final b
         if (0 == nBytes) {
             return dst;
         }
-        if ((nBytes - 1) * 8 + srcPos >= 16) {
+        if ((nBytes - 1) * Byte.SIZE + srcPos >= Short.SIZE) {
             throw new IllegalArgumentException("(nBytes - 1) * 8 + srcPos >= 16");
         }
         for (int i = 0; i < nBytes; i++) {
-            final int shift = i * 8 + srcPos;
+            final int shift = i * Byte.SIZE + srcPos;
             dst[dstPos + i] = (byte) (0xff & src >> shift);
         }
         return dst;
@@ -1341,7 +1341,7 @@ public static String shortToHex(final short src, final int srcPos, final String
         if (0 == nHexs) {
             return dstInit;
         }
-        if ((nHexs - 1) * 4 + srcPos >= 16) {
+        if ((nHexs - 1) * 4 + srcPos >= Short.SIZE) {
             throw new IllegalArgumentException("(nHexs - 1) * 4 + srcPos >= 16");
         }
         final StringBuilder sb = new StringBuilder(dstInit);
diff --git a/src/test/java/org/apache/commons/lang3/ConversionTest.java b/src/test/java/org/apache/commons/lang3/ConversionTest.java
index c0a4d3201..2fab1f912 100644
--- a/src/test/java/org/apache/commons/lang3/ConversionTest.java
+++ b/src/test/java/org/apache/commons/lang3/ConversionTest.java
@@ -49,7 +49,7 @@ static String dbgPrint(final boolean[] src) {
     }
 
     @ParameterizedTest
-    @ValueSource(ints = {Integer.MIN_VALUE -1, 8, 9, Integer.MAX_VALUE})
+    @ValueSource(ints = { Integer.MIN_VALUE, -1, 8, 9, Integer.MAX_VALUE })
     public void binaryBeMsb0ToHexDigitPosOutsideArray(final int index) {
         assertIndexOutOfBoundsException(() -> Conversion.binaryBeMsb0ToHexDigit(new boolean[8], index));
     }