简体   繁体   中英

Generate java code in modelio

I created a UML class diagram im Modelio, now I need to implement this diagram in Java. Is there any possibility to generate Java code out of a class diagram? I just want to export the classes and prototypes of the methods. I have already tried tu use "java designer 3.1.00", but i could not figure out if/how i can generate class files with this extention.

Another way is write a macro using Modelio API. This is a very simple example for PHP (only for prepare class and methods):

if (selectedElements.size() > 0):
    for c in selectedElements:
        print "<?php"
        print ""
        print "class " + c.getName()
        print "{"

        child = c.getCompositionChildren()       
        for a in child:
            if (a.getMClass().getName() == "Operation"):             
                print " public function " + a.getName() + "()"
                print " {"
                print " }"
                print ""                     
        print "}"
        print ""
else:
    print "No element has been selected."

APIs for macros is here . API also allows you to save your generated code to files (for example you can use package names as directories and class names as file names).

Here is the Modelio Java Designer user manual where you will find all you need concerning Java code generation.

But for generating Java code you have to say, by adding stereotypes, that your UML element (package, Java, enumeration, etc.) can be used for Java code generation. For that please take a look at this post .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM