Home » Modeling » EMF » Generics for multiplicity-many references
|
Re: Generics for multiplicity-many references [message #422105 is a reply to message #422103] |
Fri, 22 August 2008 05:41 |
Tom Crockett Messages: 54 Registered: July 2009 |
Member |
|
|
Ah, I think I've uncovered what's going on, but I'm not sure how to fix
it. I manually created a genmodel via the wizard, importing from the same
xsd file, and this time when I generated the source code it correctly used
generics. So I diffed the two genmodels and, surprise surprise, these two
changes came up:
Attribute complianceLevel:GenJDKLevel in Apples has changed from 5.0 to 1.4
Attribute runtimeVersion:GenRuntimeVersion in Apples has changed from 2.4
to 2.2
So is there a way to inform the ant task to use 5.0/2.4?
Thomas Crockett wrote:
> Hi, I'm having a strange problem where when I generate java code for
> models with multiplicity-many references, the resulting ELists are
> unparameterized. I am generating the code from XML Schema, using the
> XSD2Java ant task. Simplified, the XSD version of the type looks basically
> like this (Apple is defined elsewhere):
> <xs:element name="Basket">
> <xs:complexType ecore:name="Basket">
> <xs:sequence>
> <xs:element name="Apples" ecore:name="Apples" type="Apple"
> minOccurs="0" maxOccurs="unbounded"/>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> From this I get the following interface:
> public interface Basket extends EObject
> {
> /**
> * Returns the value of the '<em><b>Apples</b></em>' containment
> reference list.
> * The list contents are of type {@link test.Apple}.
> * <!-- begin-user-doc -->
> * <p>
> * If the meaning of the '<em>Apples</em>' containment reference list
> isn't clear,
> * there really should be more of a description here...
> * </p>
> * <!-- end-user-doc -->
> * @return the value of the '<em>Apples</em>' containment reference list.
> * @see test.ApplesPackage#getBasket_Apples()
> * @model type="test.Apple" containment="true"
> * extendedMetaData="kind='element' name='Apples'
> namespace='##targetNamespace'"
> * @generated
> */
> EList getApples();
> } // Basket
> Why doesn't that method look like this:
> EList<Apple> getApples();
> ?
> I've never had a problem with this before, when the source of my model was
> annotated interfaces, but coming from XSD there seems to be a problem. Any
> ideas?
|
|
|
Re: Generics for multiplicity-many references [message #422106 is a reply to message #422105] |
Fri, 22 August 2008 06:08 |
Tom Crockett Messages: 54 Registered: July 2009 |
Member |
|
|
Aha! I figured out the right argument through trial and error. By adding
this:
<arg line="-jdkLevel 5.0"/>
to the ant task, I was able to make it generate generics. Still, I wonder
why that's not the default?
Thomas Crockett wrote:
> Ah, I think I've uncovered what's going on, but I'm not sure how to fix
> it. I manually created a genmodel via the wizard, importing from the same
> xsd file, and this time when I generated the source code it correctly used
> generics. So I diffed the two genmodels and, surprise surprise, these two
> changes came up:
> Attribute complianceLevel:GenJDKLevel in Apples has changed from 5.0 to 1.4
> Attribute runtimeVersion:GenRuntimeVersion in Apples has changed from 2.4
> to 2.2
> So is there a way to inform the ant task to use 5.0/2.4?
> Thomas Crockett wrote:
>> Hi, I'm having a strange problem where when I generate java code for
>> models with multiplicity-many references, the resulting ELists are
>> unparameterized. I am generating the code from XML Schema, using the
>> XSD2Java ant task. Simplified, the XSD version of the type looks basically
>> like this (Apple is defined elsewhere):
>> <xs:element name="Basket">
>> <xs:complexType ecore:name="Basket">
>> <xs:sequence>
>> <xs:element name="Apples" ecore:name="Apples" type="Apple"
>> minOccurs="0" maxOccurs="unbounded"/>
>> </xs:sequence>
>> </xs:complexType>
>> </xs:element>
>> From this I get the following interface:
>> public interface Basket extends EObject
>> {
>> /**
>> * Returns the value of the '<em><b>Apples</b></em>' containment
>> reference list.
>> * The list contents are of type {@link test.Apple}.
>> * <!-- begin-user-doc -->
>> * <p>
>> * If the meaning of the '<em>Apples</em>' containment reference list
>> isn't clear,
>> * there really should be more of a description here...
>> * </p>
>> * <!-- end-user-doc -->
>> * @return the value of the '<em>Apples</em>' containment reference list.
>> * @see test.ApplesPackage#getBasket_Apples()
>> * @model type="test.Apple" containment="true"
>> * extendedMetaData="kind='element' name='Apples'
>> namespace='##targetNamespace'"
>> * @generated
>> */
>> EList getApples();
>> } // Basket
>> Why doesn't that method look like this:
>> EList<Apple> getApples();
>> ?
>> I've never had a problem with this before, when the source of my model was
>> annotated interfaces, but coming from XSD there seems to be a problem. Any
>> ideas?
|
|
|
Re: Generics for multiplicity-many references [message #422115 is a reply to message #422106] |
Fri, 22 August 2008 09:55 |
Ed Merks Messages: 33137 Registered: July 2009 |
Senior Member |
|
|
Thomas,
When 5.0 supported was added, it was new, and you don't generally want
to make defaults change for existing clients.
Thomas Crockett wrote:
> Aha! I figured out the right argument through trial and error. By
> adding this:
>
> <arg line="-jdkLevel 5.0"/>
>
> to the ant task, I was able to make it generate generics. Still, I
> wonder why that's not the default?
>
> Thomas Crockett wrote:
>
>> Ah, I think I've uncovered what's going on, but I'm not sure how to
>> fix it. I manually created a genmodel via the wizard, importing from
>> the same xsd file, and this time when I generated the source code it
>> correctly used generics. So I diffed the two genmodels and, surprise
>> surprise, these two changes came up:
>
>> Attribute complianceLevel:GenJDKLevel in Apples has changed from 5.0
>> to 1.4
>> Attribute runtimeVersion:GenRuntimeVersion in Apples has changed from
>> 2.4 to 2.2
>
>> So is there a way to inform the ant task to use 5.0/2.4?
>
>> Thomas Crockett wrote:
>
>>> Hi, I'm having a strange problem where when I generate java code for
>>> models with multiplicity-many references, the resulting ELists are
>>> unparameterized. I am generating the code from XML Schema, using the
>>> XSD2Java ant task. Simplified, the XSD version of the type looks
>>> basically like this (Apple is defined elsewhere):
>
>>> <xs:element name="Basket">
>>> <xs:complexType ecore:name="Basket">
>>> <xs:sequence>
>>> <xs:element name="Apples" ecore:name="Apples"
>>> type="Apple" minOccurs="0" maxOccurs="unbounded"/>
>>> </xs:sequence>
>>> </xs:complexType>
>>> </xs:element>
>
>>> From this I get the following interface:
>
>
>
>>> public interface Basket extends EObject
>>> {
>>> /**
>>> * Returns the value of the '<em><b>Apples</b></em>' containment
>>> reference list.
>>> * The list contents are of type {@link test.Apple}.
>>> * <!-- begin-user-doc -->
>>> * <p>
>>> * If the meaning of the '<em>Apples</em>' containment reference
>>> list isn't clear,
>>> * there really should be more of a description here...
>>> * </p>
>>> * <!-- end-user-doc -->
>>> * @return the value of the '<em>Apples</em>' containment
>>> reference list.
>>> * @see test.ApplesPackage#getBasket_Apples()
>>> * @model type="test.Apple" containment="true"
>>> * extendedMetaData="kind='element' name='Apples'
>>> namespace='##targetNamespace'"
>>> * @generated
>>> */
>>> EList getApples();
>
>>> } // Basket
>
>>> Why doesn't that method look like this:
>
>>> EList<Apple> getApples();
>
>>> ?
>
>>> I've never had a problem with this before, when the source of my
>>> model was annotated interfaces, but coming from XSD there seems to
>>> be a problem. Any ideas?
>
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Goto Forum:
Current Time: Fri Apr 19 20:23:40 GMT 2024
Powered by FUDForum. Page generated in 0.03174 seconds
|