Is it possible to model operation parameters as vararg in Eclipse/EMF?










2














I'm trying to find a way to model an operation with a vararg input parameter.



The model should generate an interface as shown below.



/**
* ...
* @generated
*/
public interface Content extends EObject
/**
* ...
* @generated
*/
List<Definition> getDefinitionsByLabels(String... label);





Please don't answer with workarounds because I'm trying to update a model of an existing (large) code base (that was "manually" developed further post generation).



So far investigating this didn't look promising, but I didn't want to give up on this aspect without asking a question here.



Example Class Diagram










share|improve this question




























    2














    I'm trying to find a way to model an operation with a vararg input parameter.



    The model should generate an interface as shown below.



    /**
    * ...
    * @generated
    */
    public interface Content extends EObject
    /**
    * ...
    * @generated
    */
    List<Definition> getDefinitionsByLabels(String... label);





    Please don't answer with workarounds because I'm trying to update a model of an existing (large) code base (that was "manually" developed further post generation).



    So far investigating this didn't look promising, but I didn't want to give up on this aspect without asking a question here.



    Example Class Diagram










    share|improve this question


























      2












      2








      2







      I'm trying to find a way to model an operation with a vararg input parameter.



      The model should generate an interface as shown below.



      /**
      * ...
      * @generated
      */
      public interface Content extends EObject
      /**
      * ...
      * @generated
      */
      List<Definition> getDefinitionsByLabels(String... label);





      Please don't answer with workarounds because I'm trying to update a model of an existing (large) code base (that was "manually" developed further post generation).



      So far investigating this didn't look promising, but I didn't want to give up on this aspect without asking a question here.



      Example Class Diagram










      share|improve this question















      I'm trying to find a way to model an operation with a vararg input parameter.



      The model should generate an interface as shown below.



      /**
      * ...
      * @generated
      */
      public interface Content extends EObject
      /**
      * ...
      * @generated
      */
      List<Definition> getDefinitionsByLabels(String... label);





      Please don't answer with workarounds because I'm trying to update a model of an existing (large) code base (that was "manually" developed further post generation).



      So far investigating this didn't look promising, but I didn't want to give up on this aspect without asking a question here.



      Example Class Diagram







      java eclipse emf eclipse-emf






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 7 at 14:24









      Lii

      6,84044159




      6,84044159










      asked Nov 5 at 13:55









      KayleeTheMech

      11310




      11310






















          2 Answers
          2






          active

          oldest

          votes


















          1














          Since varargs is not supported directly by the code generator of EMF, someone asked to make the upper limit a marker for varargs.
          The bug report is pending, i.e. the requested feature is not available:
          https://bugs.eclipse.org/bugs/show_bug.cgi?id=337052






          share|improve this answer




















          • makes sense, thanks erdal
            – KayleeTheMech
            Nov 15 at 14:17


















          0














          If what you want is a var-arg Java method on your model class, and you don't need a proper EMF operation, then this is possible to solve:



          Make your model class implement a Java interface, where the vararg method is declared.



          Java file:



          public interface InterfaceWithVarargMethod 
          public void varArgMethod(String... arg);



          Xcore file:



          @GenModel(modelDirectory="/EMF_Trying/src-gen")
          package emf_trying

          interface InterfaceWithVarargMethod wraps InterfaceWithVarargMethod

          class ModelObject extends InterfaceWithVarargMethod



          An implementation of ModelObjectImpl without the var-arg method will get generated. You have to edit the generated code and add the var-arg method for the code to compile:



          public class ModelObjectImpl extends MinimalEObjectImpl.Container implements ModelObject 
          /**
          * @generated NOT
          */
          @Override
          public void m(String... arg)
          // Implementation of var-arg method


          ...



          Maybe it is possible to find some variation of this solution where you don't have to edit the generated code. For example by making your model objects extend a Java class instead of an interface.






          share|improve this answer




















            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53155801%2fis-it-possible-to-model-operation-parameters-as-vararg-in-eclipse-emf%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            Since varargs is not supported directly by the code generator of EMF, someone asked to make the upper limit a marker for varargs.
            The bug report is pending, i.e. the requested feature is not available:
            https://bugs.eclipse.org/bugs/show_bug.cgi?id=337052






            share|improve this answer




















            • makes sense, thanks erdal
              – KayleeTheMech
              Nov 15 at 14:17















            1














            Since varargs is not supported directly by the code generator of EMF, someone asked to make the upper limit a marker for varargs.
            The bug report is pending, i.e. the requested feature is not available:
            https://bugs.eclipse.org/bugs/show_bug.cgi?id=337052






            share|improve this answer




















            • makes sense, thanks erdal
              – KayleeTheMech
              Nov 15 at 14:17













            1












            1








            1






            Since varargs is not supported directly by the code generator of EMF, someone asked to make the upper limit a marker for varargs.
            The bug report is pending, i.e. the requested feature is not available:
            https://bugs.eclipse.org/bugs/show_bug.cgi?id=337052






            share|improve this answer












            Since varargs is not supported directly by the code generator of EMF, someone asked to make the upper limit a marker for varargs.
            The bug report is pending, i.e. the requested feature is not available:
            https://bugs.eclipse.org/bugs/show_bug.cgi?id=337052







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 12 at 6:03









            erdal.karaca

            4451318




            4451318











            • makes sense, thanks erdal
              – KayleeTheMech
              Nov 15 at 14:17
















            • makes sense, thanks erdal
              – KayleeTheMech
              Nov 15 at 14:17















            makes sense, thanks erdal
            – KayleeTheMech
            Nov 15 at 14:17




            makes sense, thanks erdal
            – KayleeTheMech
            Nov 15 at 14:17













            0














            If what you want is a var-arg Java method on your model class, and you don't need a proper EMF operation, then this is possible to solve:



            Make your model class implement a Java interface, where the vararg method is declared.



            Java file:



            public interface InterfaceWithVarargMethod 
            public void varArgMethod(String... arg);



            Xcore file:



            @GenModel(modelDirectory="/EMF_Trying/src-gen")
            package emf_trying

            interface InterfaceWithVarargMethod wraps InterfaceWithVarargMethod

            class ModelObject extends InterfaceWithVarargMethod



            An implementation of ModelObjectImpl without the var-arg method will get generated. You have to edit the generated code and add the var-arg method for the code to compile:



            public class ModelObjectImpl extends MinimalEObjectImpl.Container implements ModelObject 
            /**
            * @generated NOT
            */
            @Override
            public void m(String... arg)
            // Implementation of var-arg method


            ...



            Maybe it is possible to find some variation of this solution where you don't have to edit the generated code. For example by making your model objects extend a Java class instead of an interface.






            share|improve this answer

























              0














              If what you want is a var-arg Java method on your model class, and you don't need a proper EMF operation, then this is possible to solve:



              Make your model class implement a Java interface, where the vararg method is declared.



              Java file:



              public interface InterfaceWithVarargMethod 
              public void varArgMethod(String... arg);



              Xcore file:



              @GenModel(modelDirectory="/EMF_Trying/src-gen")
              package emf_trying

              interface InterfaceWithVarargMethod wraps InterfaceWithVarargMethod

              class ModelObject extends InterfaceWithVarargMethod



              An implementation of ModelObjectImpl without the var-arg method will get generated. You have to edit the generated code and add the var-arg method for the code to compile:



              public class ModelObjectImpl extends MinimalEObjectImpl.Container implements ModelObject 
              /**
              * @generated NOT
              */
              @Override
              public void m(String... arg)
              // Implementation of var-arg method


              ...



              Maybe it is possible to find some variation of this solution where you don't have to edit the generated code. For example by making your model objects extend a Java class instead of an interface.






              share|improve this answer























                0












                0








                0






                If what you want is a var-arg Java method on your model class, and you don't need a proper EMF operation, then this is possible to solve:



                Make your model class implement a Java interface, where the vararg method is declared.



                Java file:



                public interface InterfaceWithVarargMethod 
                public void varArgMethod(String... arg);



                Xcore file:



                @GenModel(modelDirectory="/EMF_Trying/src-gen")
                package emf_trying

                interface InterfaceWithVarargMethod wraps InterfaceWithVarargMethod

                class ModelObject extends InterfaceWithVarargMethod



                An implementation of ModelObjectImpl without the var-arg method will get generated. You have to edit the generated code and add the var-arg method for the code to compile:



                public class ModelObjectImpl extends MinimalEObjectImpl.Container implements ModelObject 
                /**
                * @generated NOT
                */
                @Override
                public void m(String... arg)
                // Implementation of var-arg method


                ...



                Maybe it is possible to find some variation of this solution where you don't have to edit the generated code. For example by making your model objects extend a Java class instead of an interface.






                share|improve this answer












                If what you want is a var-arg Java method on your model class, and you don't need a proper EMF operation, then this is possible to solve:



                Make your model class implement a Java interface, where the vararg method is declared.



                Java file:



                public interface InterfaceWithVarargMethod 
                public void varArgMethod(String... arg);



                Xcore file:



                @GenModel(modelDirectory="/EMF_Trying/src-gen")
                package emf_trying

                interface InterfaceWithVarargMethod wraps InterfaceWithVarargMethod

                class ModelObject extends InterfaceWithVarargMethod



                An implementation of ModelObjectImpl without the var-arg method will get generated. You have to edit the generated code and add the var-arg method for the code to compile:



                public class ModelObjectImpl extends MinimalEObjectImpl.Container implements ModelObject 
                /**
                * @generated NOT
                */
                @Override
                public void m(String... arg)
                // Implementation of var-arg method


                ...



                Maybe it is possible to find some variation of this solution where you don't have to edit the generated code. For example by making your model objects extend a Java class instead of an interface.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 9 hours ago









                Lii

                6,84044159




                6,84044159



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53155801%2fis-it-possible-to-model-operation-parameters-as-vararg-in-eclipse-emf%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    這個網誌中的熱門文章

                    Barbados

                    How to read a connectionString WITH PROVIDER in .NET Core?

                    Node.js Script on GitHub Pages or Amazon S3