Tweaked some Java code.

This commit is contained in:
Project Nayuki 2018-08-26 02:33:49 +00:00
parent 1edde0571a
commit 7d7a9b4820
1 changed files with 2 additions and 1 deletions

View File

@ -214,9 +214,9 @@ public final class QrCode {
public QrCode(int ver, Ecc ecl, byte[] dataCodewords, int mask) {
// Check arguments
errorCorrectionLevel = Objects.requireNonNull(ecl);
Objects.requireNonNull(dataCodewords);
if (ver < MIN_VERSION || ver > MAX_VERSION || mask < -1 || mask > 7)
throw new IllegalArgumentException("Value out of range");
Objects.requireNonNull(dataCodewords);
// Initialize fields
version = ver;
@ -438,6 +438,7 @@ public final class QrCode {
// Returns a new byte string representing the given data with the appropriate error correction
// codewords appended to it, based on this object's version and error correction level.
private byte[] addEccAndInterleave(byte[] data) {
Objects.requireNonNull(data);
if (data.length != getNumDataCodewords(version, errorCorrectionLevel))
throw new IllegalArgumentException();