Skip to content

Commit d818c31

Browse files
committed
minor simplification of null checks
1 parent 5d4d6d2 commit d818c31

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

src/main/java/com/fasterxml/jackson/core/JsonGenerator.java

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import java.io.*;
88
import java.math.BigDecimal;
99
import java.math.BigInteger;
10+
import java.util.Objects;
1011

1112
import com.fasterxml.jackson.core.JsonParser.NumberType;
1213
import com.fasterxml.jackson.core.io.CharacterEscapes;
@@ -514,9 +515,7 @@ public void setSchema(FormatSchema schema) {
514515
*/
515516
public void writeArray(int[] array, int offset, int length) throws IOException
516517
{
517-
if (array == null) {
518-
throw new IllegalArgumentException("null array");
519-
}
518+
Objects.requireNonNull(array, "null 'array' argument");
520519
_verifyOffsets(array.length, offset, length);
521520
writeStartArray(array, length);
522521
for (int i = offset, end = offset+length; i < end; ++i) {
@@ -536,9 +535,7 @@ public void writeArray(int[] array, int offset, int length) throws IOException
536535
*/
537536
public void writeArray(long[] array, int offset, int length) throws IOException
538537
{
539-
if (array == null) {
540-
throw new IllegalArgumentException("null array");
541-
}
538+
Objects.requireNonNull(array, "null 'array' argument");
542539
_verifyOffsets(array.length, offset, length);
543540
writeStartArray(array, length);
544541
for (int i = offset, end = offset+length; i < end; ++i) {
@@ -558,9 +555,7 @@ public void writeArray(long[] array, int offset, int length) throws IOException
558555
*/
559556
public void writeArray(double[] array, int offset, int length) throws IOException
560557
{
561-
if (array == null) {
562-
throw new IllegalArgumentException("null array");
563-
}
558+
Objects.requireNonNull(array, "null 'array' argument");
564559
_verifyOffsets(array.length, offset, length);
565560
writeStartArray(array, length);
566561
for (int i = offset, end = offset+length; i < end; ++i) {
@@ -574,17 +569,13 @@ public void writeArray(double[] array, int offset, int length) throws IOExceptio
574569
* array (sequence of {@link JsonToken#START_ARRAY}, zero or
575570
* more {@link JsonToken#VALUE_STRING}, {@link JsonToken#END_ARRAY})
576571
*
577-
* @since 2.11
578-
*
579572
* @param array Array that contains values to write
580573
* @param offset Offset of the first element to write, within array
581574
* @param length Number of elements in array to write, from `offset` to `offset + len - 1`
582575
*/
583576
public void writeArray(String[] array, int offset, int length) throws IOException
584577
{
585-
if (array == null) {
586-
throw new IllegalArgumentException("null array");
587-
}
578+
Objects.requireNonNull(array, "null 'array' argument");
588579
_verifyOffsets(array.length, offset, length);
589580
writeStartArray(array, length);
590581
for (int i = offset, end = offset+length; i < end; ++i) {

0 commit comments

Comments
 (0)