commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Benedikt Ritter <brit...@apache.org>
Subject Re: [csv] CSVRecord implements Map<String, String>
Date Wed, 15 Jan 2014 06:17:12 GMT
A wrapper of some kind like Adrian suggested sounds like the way to go
here. Maybe we could have something like:

Map<String, String> map = CSVRecordUtils.toMap(record);

Benedikt

2014/1/15 Gary Gregory <garydgregory@gmail.com>

> I have a complex immutable class with a constructor that takes many fields.
>
> I have a factory that builds instances of this class.
>
> At runtime, some of the data to build the objects come from CSVRecord
> objects.
>
> At other times, like for tests, I want build sometimes I build the objects
> from CSVRecord and sometimes from Map objects. The factory uses the Map
> like a CSVRecord. This let's me build simple, medium and large objects
> using a Map, which is handy for the test, without having to deal with all
> of the fields in a real record.
>
> Right now, I have duplicate looking code in the factory methods since
> CSVRecord and Map<String, String> are not friends.
>
> Hence my request. Also consider that one cannot do 'new CSVRecord()' like
> one can 'new HashMap<String, String>()'.
>
> Thanks,
> Gary
>
>
> On Tue, Jan 14, 2014 at 6:11 PM, Emmanuel Bourg <ebourg@apache.org> wrote:
>
> > I'm not fond of the idea at the first glance. What is your use case?
> >
> > Emmanuel
> >
> >
> > Le 14/01/2014 23:27, Gary Gregory a écrit :
> > > Hi All:
> > >
> > > Any thoughts on making CSVRecord implement Map<String, String> ?
> > >
> > > It would certainly help remove duplicate code in a use case of mine.
> > >
> > > Gary
> > >
> >
> >
> > ---------------------------------------------------------------------
> > 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
>



-- 
http://people.apache.org/~britter/
http://www.systemoutprintln.de/
http://twitter.com/BenediktRitter
http://github.com/britter

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