Skip to content

Commit adc4faa

Browse files
committed
Replace org.apache.commons.csv.Assertions.notNull() with
Objects.requireNonNull().
1 parent bc24199 commit adc4faa

7 files changed

Lines changed: 126 additions & 205 deletions

File tree

src/changes/changes.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
<action type="update" dev="ggregory" due-to="Chen">Improve CSVRecord and CSVPrinter code coverage #66.</action>
5555
<action type="update" dev="ggregory" due-to="Chen">Improve lexer and token coverage #67.</action>
5656
<action issue="CSV-211" type="fix" dev="ggregory" due-to="Alpesh Kulkarni, Chen">CSVFormat.format trims last delimiter if the delimiter is a white space #71.</action>
57+
<action type="update" dev="ggregory" due-to="Gary Gregory">Replace org.apache.commons.csv.Assertions.notNull() with Objects.requireNonNull().</action>
5758
</release>
5859
<release version="1.8" date="2020-02-01" description="Feature and bug fix release (Java 8).
5960

src/main/java/org/apache/commons/csv/Assertions.java

Lines changed: 0 additions & 38 deletions
This file was deleted.

src/main/java/org/apache/commons/csv/CSVParser.java

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import java.util.List;
4040
import java.util.Map;
4141
import java.util.NoSuchElementException;
42+
import java.util.Objects;
4243
import java.util.TreeMap;
4344

4445
/**
@@ -200,8 +201,8 @@ public void remove() {
200201
*/
201202
@SuppressWarnings("resource")
202203
public static CSVParser parse(final File file, final Charset charset, final CSVFormat format) throws IOException {
203-
Assertions.notNull(file, "file");
204-
Assertions.notNull(format, "format");
204+
Objects.requireNonNull(file, "file");
205+
Objects.requireNonNull(format, "format");
205206
return new CSVParser(new InputStreamReader(new FileInputStream(file), charset), format);
206207
}
207208

@@ -229,8 +230,8 @@ public static CSVParser parse(final File file, final Charset charset, final CSVF
229230
@SuppressWarnings("resource")
230231
public static CSVParser parse(final InputStream inputStream, final Charset charset, final CSVFormat format)
231232
throws IOException {
232-
Assertions.notNull(inputStream, "inputStream");
233-
Assertions.notNull(format, "format");
233+
Objects.requireNonNull(inputStream, "inputStream");
234+
Objects.requireNonNull(format, "format");
234235
return parse(new InputStreamReader(inputStream, charset), format);
235236
}
236237

@@ -251,8 +252,8 @@ public static CSVParser parse(final InputStream inputStream, final Charset chars
251252
* @since 1.5
252253
*/
253254
public static CSVParser parse(final Path path, final Charset charset, final CSVFormat format) throws IOException {
254-
Assertions.notNull(path, "path");
255-
Assertions.notNull(format, "format");
255+
Objects.requireNonNull(path, "path");
256+
Objects.requireNonNull(format, "format");
256257
return parse(Files.newInputStream(path), charset, format);
257258
}
258259

@@ -293,8 +294,8 @@ public static CSVParser parse(final Reader reader, final CSVFormat format) throw
293294
* If an I/O error occurs
294295
*/
295296
public static CSVParser parse(final String string, final CSVFormat format) throws IOException {
296-
Assertions.notNull(string, "string");
297-
Assertions.notNull(format, "format");
297+
Objects.requireNonNull(string, "string");
298+
Objects.requireNonNull(format, "format");
298299

299300
return new CSVParser(new StringReader(string), format);
300301
}
@@ -322,9 +323,9 @@ public static CSVParser parse(final String string, final CSVFormat format) throw
322323
* If an I/O error occurs
323324
*/
324325
public static CSVParser parse(final URL url, final Charset charset, final CSVFormat format) throws IOException {
325-
Assertions.notNull(url, "url");
326-
Assertions.notNull(charset, "charset");
327-
Assertions.notNull(format, "format");
326+
Objects.requireNonNull(url, "url");
327+
Objects.requireNonNull(charset, "charset");
328+
Objects.requireNonNull(format, "format");
328329

329330
return new CSVParser(new InputStreamReader(url.openStream(), charset), format);
330331
}
@@ -403,8 +404,8 @@ public CSVParser(final Reader reader, final CSVFormat format) throws IOException
403404
@SuppressWarnings("resource")
404405
public CSVParser(final Reader reader, final CSVFormat format, final long characterOffset, final long recordNumber)
405406
throws IOException {
406-
Assertions.notNull(reader, "reader");
407-
Assertions.notNull(format, "format");
407+
Objects.requireNonNull(reader, "reader");
408+
Objects.requireNonNull(format, "format");
408409

409410
this.format = format;
410411
this.lexer = new Lexer(format, new ExtendedBufferedReader(reader));

src/main/java/org/apache/commons/csv/CSVPrinter.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import java.sql.ResultSet;
2929
import java.sql.SQLException;
3030
import java.util.Arrays;
31+
import java.util.Objects;
3132

3233
/**
3334
* Prints values in a {@link CSVFormat CSV format}.
@@ -92,8 +93,8 @@ public final class CSVPrinter implements Flushable, Closeable {
9293
* thrown if the parameters of the format are inconsistent or if either out or format are null.
9394
*/
9495
public CSVPrinter(final Appendable out, final CSVFormat format) throws IOException {
95-
Assertions.notNull(out, "out");
96-
Assertions.notNull(format, "format");
96+
Objects.requireNonNull(out, "out");
97+
Objects.requireNonNull(format, "format");
9798

9899
this.out = out;
99100
this.format = format;

src/test/java/org/apache/commons/csv/AssertionsTest.java

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)