2014/1/17 sebb <seb...@gmail.com> > On 17 January 2014 00:57, Gary Gregory <garydgreg...@gmail.com> wrote: > > On Thu, Jan 16, 2014 at 7:24 PM, sebb <seb...@gmail.com> wrote: > > > >> On 16 January 2014 20:58, Gary Gregory <garydgreg...@gmail.com> wrote: > >> > On Thu, Jan 16, 2014 at 7:49 AM, Emmanuel Bourg <ebo...@apache.org> > >> wrote: > >> > > >> >> Le 15/01/2014 14:04, Gary Gregory a écrit : > >> >> > >> >> > Uh, I want to go the other way around. See my use case. > >> >> > >> >> Why isn't this suitable to your use case? You could write: > >> >> > >> >> factory.create(record.toMap()); > >> >> > >> >> and then remove the create(CSVRecord) method with the duplicated > >> >> implementation. > >> >> > >> >> What am I missing? > >> >> > >> > > >> > That would work. What is still not clean or OO is that toMap() means > >> > nothing when no headers are defined. > >> > > >> > I've split the record into a mapped record subclass here: > >> > > >> > https://issues.apache.org/jira/browse/CSV-104 > >> > > >> > Thoughts? > >> > > >> > We can still have toMap() implemented on top of the code now, but it > >> would > >> > have to return null if there are no headers. > >> > >> Why not return an empty Map? > >> > > > > An empty map is, well, empty but the record is not empty, so that's kinda > > confusing, > > Depends on the method Javadoc whether it is confusing or not. > > If toMap() is defined to return the empty Map if there are no column > names, then that is clear to me. > > AFAICT an empty map cannot be generated otherwise. > > Or is there a situation where an empty map means something usefully > distinct from no header names? > > > whereas null is clearly something that does exist. If toMap() is > > only in the subclass, then there is no problem. > > > > The alternative is to create a real map with columns name "Column1", > > "Column2", and so on. But then that would be confusing because > > record.get("Column1) would give you null whereas > > record.toMap().get("Column1") would give you a value. Then we get to talk > > about having "Column1", "Column2"... as the default column names if none > > are provided... kinda too clever. > > Yuk. > > > All of this to say that over time it is likely as we need to provide more > > APIs, and it seems easier to say null than an empty structure. First > > toMap(), then toProperties() and so on. > > I don't think that follows. > > > The KISS solution is toMap() -> null for unmapped records IMO. > > IMO the empty map is better. >
To me this sounds more like IllegalStateException... > > > Gary > > > > > >> > >> > Gary > >> > > >> > > >> >> > >> >> Emmanuel Bourg > >> >> > >> >> > >> >> --------------------------------------------------------------------- > >> >> 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 > >> > >> --------------------------------------------------------------------- > >> 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 > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org > For additional commands, e-mail: dev-h...@commons.apache.org > > -- http://people.apache.org/~britter/ http://www.systemoutprintln.de/ http://twitter.com/BenediktRitter http://github.com/britter