mirror of
https://github.com/apache/commons-csv.git
synced 2025-02-13 05:26:28 +00:00
Let a null input to CSVRecord#get(Enum) fail in CSVRecord#get(String).
This commit is contained in:
parent
e3eca25d13
commit
7c5c08921c
@ -24,6 +24,7 @@ import java.util.LinkedHashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A CSV record parsed from a CSV file.
|
* A CSV record parsed from a CSV file.
|
||||||
@ -65,7 +66,7 @@ public final class CSVRecord implements Serializable, Iterable<String> {
|
|||||||
* @return the String at the given enum String
|
* @return the String at the given enum String
|
||||||
*/
|
*/
|
||||||
public String get(final Enum<?> e) {
|
public String get(final Enum<?> e) {
|
||||||
return get(e.toString());
|
return get(Objects.toString(e, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -91,6 +91,11 @@ public class CSVRecordTest {
|
|||||||
assertThrows(IllegalArgumentException.class, () -> recordWithHeader.get(EnumFixture.UNKNOWN_COLUMN));
|
assertThrows(IllegalArgumentException.class, () -> recordWithHeader.get(EnumFixture.UNKNOWN_COLUMN));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetNullEnum() {
|
||||||
|
assertThrows(IllegalArgumentException.class, () -> recordWithHeader.get((Enum<?>) null));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetUnmappedName() {
|
public void testGetUnmappedName() {
|
||||||
assertThrows(IllegalArgumentException.class, () -> assertNull(recordWithHeader.get("fourth")));
|
assertThrows(IllegalArgumentException.class, () -> assertNull(recordWithHeader.get("fourth")));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user