commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary Gregory <>
Subject Re: [csv] CSVRecord and Map<String, String>
Date Tue, 21 Jan 2014 14:08:34 GMT
On Tue, Jan 21, 2014 at 8:58 AM, Emmanuel Bourg <> wrote:

> Le 21/01/2014 14:44, Gary Gregory a écrit :
> > That's what the current impl does: a new HashMap with String keys and
> > String values. Since Strings are immutable, they do not need to be a
> > 'copy'. Unless I misunderstand you.
> That's an independent copy of the structure of the record. Changes to
> the map are not reflected in the record (and shouldn't).

OK, that's what the impl does now, it's clear and simple.

> An alternative would be a Map backed by the record. Calling
> map.get("foo") would translate to record.get("foo"), etc. We did
> something similar in [configuration] (read/write here).

This kind of complication is unnecessary IMO, why not just have the record
implement Map? The only wrinkle is for unmapped records. Stepping back from
that leads to having a record vs. mapped record classes, which seems to
make the code more complicated. At least my experiment with generics was
not ideal (see JIRA), but it could be made simpler by just doing a type
cast instead of using generics. IF we think the 80/20 rule applies and that
80% of CSV files are going to be mapped, then record implementing Map makes
sense, it will satisfy most of the cases with the simplest design.


> Emmanuel Bourg
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

E-Mail: |
Java Persistence with Hibernate, Second Edition<>
JUnit in Action, Second Edition <>
Spring Batch in Action <>

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message