Add CSVRecord.isSet(int) method (#52)
* Add CSVRecord.isSet(int) method * Remove unnecessary unboxing * Revert: Remove unnecessary unboxing
This commit is contained in:
parent
129641ead4
commit
4033a0199e
|
@ -214,6 +214,17 @@ public final class CSVRecord implements Serializable, Iterable<String> {
|
|||
return isMapped(name) && getHeaderMapRaw().get(name).intValue() < values.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a column with given index has a value.
|
||||
*
|
||||
* @param i
|
||||
* a column index (0-based)
|
||||
* @return whether a column with given index has a value
|
||||
*/
|
||||
public boolean isSet(final int i) {
|
||||
return 0 <= i && i < values.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an iterator over the values of this record.
|
||||
*
|
||||
|
|
|
@ -134,12 +134,22 @@ public class CSVRecordTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testIsSet() {
|
||||
public void testIsSetString() {
|
||||
assertFalse(record.isSet("first"));
|
||||
assertTrue(recordWithHeader.isSet("first"));
|
||||
assertFalse(recordWithHeader.isSet("fourth"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsSetInt() {
|
||||
assertFalse(record.isSet(-1));
|
||||
assertTrue(record.isSet(0));
|
||||
assertTrue(record.isSet(2));
|
||||
assertFalse(record.isSet(3));
|
||||
assertTrue(recordWithHeader.isSet(1));
|
||||
assertFalse(recordWithHeader.isSet(1000));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIterator() {
|
||||
int i = 0;
|
||||
|
|
Loading…
Reference in New Issue