You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@freemarker.apache.org by "Daniel Dekany (JIRA)" <ji...@apache.org> on 2017/10/26 09:48:00 UTC

[jira] [Closed] (FREEMARKER-39) DefaultObjectWrapperBuilder isn't a Builder

     [ https://issues.apache.org/jira/browse/FREEMARKER-39?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Daniel Dekany closed FREEMARKER-39.
-----------------------------------
    Resolution: Won't Do

The unreleased FreeMarker *3* branch uses fluent API-s for {{DefaultObjectWrapper.Builder}} and {{Configuration.Builder}} (and for some more), and the classes that have {{Builder}} doesn't have public constructor and are immutable. But in FreeMarker 2 fluent API-s aren't planned to be added for the reasons stated above (and due to prioritization). As this was requested for FreeMarker 2, I mark this as "Won't Do".

> DefaultObjectWrapperBuilder isn't a Builder
> -------------------------------------------
>
>                 Key: FREEMARKER-39
>                 URL: https://issues.apache.org/jira/browse/FREEMARKER-39
>             Project: Apache Freemarker
>          Issue Type: Improvement
>          Components: engine
>    Affects Versions: 2.3.25-incubating
>            Reporter: Brian Pontarelli
>
> This might not be considered a bug, but I'm logging it as one rather than an improvement. The class {{DefaultObjectWrapperBuilder}} is not actually a builder right now and it makes using it inline impossible. 
> To make it a more standard Builder pattern, all of the setter methods should be updated so that the return type is {{DefaultObjectWrapperBuilder}} and the method does a {{return this;}} at the end. This will make method chaining possible and inline use also possible. Since it uses inheritance extensively (you might want to consider unwinding this as well), you'll need to use generics and return T. Here's the class definition so that T works:
> {code:title=DefaultObjectWrapperBuilder.java}
> public class DefaultObjectWrapperBuilder extends DefaultObjectWrapperConfiguration<DefaultObjectWrapperBuilder>
> {code}
> And the parent class is defined like this:
> {code:title=DefaultObjectWrapperConfiguration.java}
> public abstract class DefaultObjectWrapperConfiguration<T> extends BeansWrapperConfiguration<T> {
> {code}
> That the final parent class is defined like this:
> {code:title=BeansWrapperConfiguration.java}
> public abstract class BeansWrapperConfiguration<T extends BeansWrapperConfiguration> implements Cloneable
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)