commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Benedikt Ritter (JIRA)" <>
Subject [jira] [Commented] (CSV-82) CSVRecord inconsistent behaviour when header mapping is not found
Date Wed, 20 Mar 2013 20:15:15 GMT


Benedikt Ritter commented on CSV-82:

Returning null is the same behavior as defined by {{java.util.Map.get(Object)}}. 
When a Map returns null on {{get(Object)}}, you don't know if this is, because null was associated
with the key (given you are using a Map implementation that allows null values) or because
no mapping for the given key is available.
Map provides {{contains(Object)}} to distinguish between the two cases.

{{CSVRecord}} OTOH provides {{isMapped(String)}} and {{isSet(String)}} for this.
> CSVRecord inconsistent behaviour when header mapping is not found
> -----------------------------------------------------------------
>                 Key: CSV-82
>                 URL:
>             Project: Commons CSV
>          Issue Type: Bug
>            Reporter: Sebb
> The CSVRecord#get(String) method has inconsistent behaviour.
> If no header mapping was provided, then it throws IllegalStateException.
> If the header name is not found, null is returned.
> Apart from being inconsistent, it might be useful in the future to be able to return
null as a column value (as distinct from the empty string).
> It should throw IllegalArgumentException for a missing header name, instead of returning

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see:

View raw message