class Hex {

  public static byte[] decode(final char... value)
  {
    if (value == null) {
      return null;
    }

    final int l = value.length;
    // CheckStyle:MagicNumber OFF
    if ((l & 0x01) != 0) {
      throw new IllegalArgumentException(
        String.format("Cannot decode odd number of characters for %s", String.valueOf(value)));
    }
    // CheckStyle:MagicNumber ON

    final byte[] decoded = new byte[l >> 1];

    // CheckStyle:MagicNumber OFF
    for (int i = 0, j = 0; j < l; i++, j += 2) {
      final int high = decode(value, j) << 4;
      final int low = decode(value, j + 1);
      decoded[i] = (byte) ((high | low) & 0xFF);
    }
    // CheckStyle:MagicNumber ON
    return decoded;
  }

  private  Hex();

}