commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary Gregory <garydgreg...@gmail.com>
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 <ebourg@apache.org> 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.

Gary


>
> http://svn.apache.org/repos/asf/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/ConfigurationMap.java
>
> Emmanuel Bourg
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>


-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

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