Simplified some Java code regarding Objects.requireNonNull().
This commit is contained in:
parent
c8f05d24d1
commit
1edde0571a
|
@ -213,7 +213,7 @@ public final class QrCode {
|
||||||
*/
|
*/
|
||||||
public QrCode(int ver, Ecc ecl, byte[] dataCodewords, int mask) {
|
public QrCode(int ver, Ecc ecl, byte[] dataCodewords, int mask) {
|
||||||
// Check arguments
|
// Check arguments
|
||||||
Objects.requireNonNull(ecl);
|
errorCorrectionLevel = Objects.requireNonNull(ecl);
|
||||||
if (ver < MIN_VERSION || ver > MAX_VERSION || mask < -1 || mask > 7)
|
if (ver < MIN_VERSION || ver > MAX_VERSION || mask < -1 || mask > 7)
|
||||||
throw new IllegalArgumentException("Value out of range");
|
throw new IllegalArgumentException("Value out of range");
|
||||||
Objects.requireNonNull(dataCodewords);
|
Objects.requireNonNull(dataCodewords);
|
||||||
|
@ -221,7 +221,6 @@ public final class QrCode {
|
||||||
// Initialize fields
|
// Initialize fields
|
||||||
version = ver;
|
version = ver;
|
||||||
size = ver * 4 + 17;
|
size = ver * 4 + 17;
|
||||||
errorCorrectionLevel = ecl;
|
|
||||||
modules = new boolean[size][size]; // Entirely white grid
|
modules = new boolean[size][size]; // Entirely white grid
|
||||||
isFunction = new boolean[size][size];
|
isFunction = new boolean[size][size];
|
||||||
|
|
||||||
|
|
|
@ -177,11 +177,10 @@ public final class QrSegment {
|
||||||
* @throws IllegalArgumentException if the character count is negative
|
* @throws IllegalArgumentException if the character count is negative
|
||||||
*/
|
*/
|
||||||
public QrSegment(Mode md, int numCh, BitBuffer data) {
|
public QrSegment(Mode md, int numCh, BitBuffer data) {
|
||||||
Objects.requireNonNull(md);
|
mode = Objects.requireNonNull(md);
|
||||||
Objects.requireNonNull(data);
|
Objects.requireNonNull(data);
|
||||||
if (numCh < 0)
|
if (numCh < 0)
|
||||||
throw new IllegalArgumentException("Invalid value");
|
throw new IllegalArgumentException("Invalid value");
|
||||||
mode = md;
|
|
||||||
numChars = numCh;
|
numChars = numCh;
|
||||||
this.data = data.clone(); // Make defensive copy
|
this.data = data.clone(); // Make defensive copy
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue