|
|
|
Re: Generated factory class [message #427084 is a reply to message #427077] |
Sat, 31 January 2009 12:57 |
Ed Merks Messages: 33142 Registered: July 2009 |
Senior Member |
|
|
Dave,
Probably our generator should be smarter to take that public
constructors flag into account. Please open a bugzilla enhancement
request and we'll add that additional guard to the base template.
Dave Ruest wrote:
> Aha, right you are! So I should at least use the "public
> constructors" flag. And if I change the template I should include a
> check for the flag in case I change my mind about the location of the
> factory.
>
> Thanks!
> D.
>
> Ed Merks wrote:
>> Dave,
>>
>> The constructor is protected so if it's in a different package from
>> the factory the pattern we have is needed...
>>
>>
>> Dave Ruest wrote:
>>> Playing with generation options, I'd set "suppress interfaces" to
>>> true, and my interface and metadata package suffixes to different
>>> values. With these values, the generated factory create() methods
>>> generate and return
>>> anonymous inner classes (correct term?) as below:
>>>
>>> public A createA() {
>>> A a = new A() {};
>>> return a;
>>> }
>>>
>>> If I set the interface and metadata packages suffixes to the same
>>> value,
>>> I get the simple constructor call I expected"
>>>
>>> public A createA() {
>>> A a = new A();
>>> return a;
>>> }
>>>
>>> I tracked this down to the snippet below, in FactoryClass.javajet:
>>>
>>> <%if (genModel.isSuppressInterfaces() &&
>>> !genPackage.getReflectionPackageName().equals(genPackage.get InterfacePackageName()))
>>> {%>{}<%}%>
>>>
>>> Finally, my question: is it safe to modify the template and remove
>>> the anonymous inner classes?
>>>
>>> D.
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.03050 seconds