On Wed, Jan 15, 2014 at 1:17 AM, Benedikt Ritter <brit...@apache.org> wrote:

> 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);
>

Uh, I want to go the other way around. See my use case.

Gary

>
> Benedikt
>
> 2014/1/15 Gary Gregory <garydgreg...@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 <ebo...@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-unsubscr...@commons.apache.org
> > > For additional commands, e-mail: dev-h...@commons.apache.org
> > >
> > >
> >
> >
> >  --
> > E-Mail: garydgreg...@gmail.com | ggreg...@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
>



-- 
E-Mail: garydgreg...@gmail.com | ggreg...@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

Reply via email to