Hi Daniel, Please see my comments below
Thanks in advance, Siegfried Goeschl > On 05.07.2020, at 13:42, Daniel Dekany <[email protected]> wrote: > > The reason I was asking is that if all functionality goes in DataSourcers, > the methods will shadow data source names. Like if you have a data source > named "empty", then DataSources.empty will not return that, instead it will > call isEmpty(). That also means that adding new methods to DataSource is > not backward compatible. So probably we will need a separate DataSources, > and DataSourceTool or something. (It's also possible to reverse priorities, > but that's even less manageable for the user.) Thanks, I was not aware of that - let me recap my understanding If I have a data source "empty", e.g. "empty=somepath/some.csv" * DataSources.empty would call DataSources.isEmpty() * DataSources["empty"] would fetch the data source "empty" * DataSources.get("empty") would fetch the data source "empty" since it calls DataSources.get(String) Some thoughts along the line * The names of a list of data sources are not enforced to be unique so the map functionality is slightly broken * Tools for me are stateless and can be potentially shared so I can not put the data sources for the current transformation in there Guess I need to think the implications over :-) > > Regarding toString() in ${DataSources["github-users.json"].toString()}. > The model can just implement TemplateScalarModel if we need a default > string representation, and then it will be just > ${DataSources["github-users.json"]}. (If you need to expose Java API, plus > call toString() for TemplateScalarModel, then you can use StringModel as > the super class.) No need for that - it was just used for diagnostic output > > > On Sat, Jul 4, 2020 at 10:27 PM Siegfried Goeschl < > [email protected] <mailto:[email protected]>> wrote: > >> Hi Daniel, >> >> Please see the examples in >> https://issues.apache.org/jira/browse/FREEMARKER-148 >> <https://issues.apache.org/jira/browse/FREEMARKER-148> < >> https://issues.apache.org/jira/browse/FREEMARKER-148 >> <https://issues.apache.org/jira/browse/FREEMARKER-148>> >> >> Thanks in advance, >> >> Siegfried Goeschl >> >> >>> On 03.07.2020, at 23:25, Daniel Dekany <[email protected]> wrote: >>> >>> How do you intend to have map semantics and still expose helper methods? >>> I'm not asking how would you implement that, but how would it look in the >>> templates? >>> >>> On Tue, Jun 30, 2020 at 9:28 PM Siegfried Goeschl < >>> [email protected]> wrote: >>> >>>> Hi folks, >>>> >>>> Following up a discussion with Daniel I would like to make "DataSources" >>>> (contains the user-supplied data sources) a bit more FTL friendly >>>> >>>> Had a quick look at it but I'm a bit lost >>>> I created a DataSourcesAdapter which extends TemplateSequenceModel & >>>> TemplateHashModel >>>> DataSources has a few additional finder methods which I can't invoke >> when >>>> exposing the DataSourcesAdapter >>>> So the question is what interfaces needs to be implemented to support >>>> sequence semantics >>>> hash map semantics >>>> arbitrary helper methods >>>> in a single adapter >>>> >>>> Thanks in advance, >>>> >>>> Siegfried Goeschl >>>> >>>> >>> >>> -- >>> Best regards, >>> Daniel Dekany >> >> > > -- > Best regards, > Daniel Dekany
