Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Generated factory class
Generated factory class [message #427071] Fri, 30 January 2009 21:02 Go to next message
Dave Ruest is currently offline Dave RuestFriend
Messages: 4
Registered: July 2009
Junior Member
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.
Re: Generated factory class [message #427074 is a reply to message #427071] Fri, 30 January 2009 23:44 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
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/
Re: Generated factory class [message #427077 is a reply to message #427074] Sat, 31 January 2009 01:26 Go to previous messageGo to next message
Dave Ruest is currently offline Dave RuestFriend
Messages: 4
Registered: July 2009
Junior Member
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.
Re: Generated factory class [message #427084 is a reply to message #427077] Sat, 31 January 2009 12:57 Go to previous message
Ed Merks is currently offline Ed MerksFriend
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/
Previous Topic:Creating in-memory EMF resource
Next Topic:Working with XML files with EMF?
Goto Forum:
  


Current Time: Fri Apr 26 18:17:14 GMT 2024

Powered by FUDForum. Page generated in 0.03050 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top