This extension for StarUML(http://staruml.io) support to generate Java code from UML model and to reverse Java code to UML model. Install this extension from Extension Manager of StarUML.
Note This extensions do not provide perfect reverse engineering which is a test and temporal feature. If you need a complete reverse engineering feature, please check other professional reverse engineering tools.
Note This extension is based on Java 1.7 Specification.
- Click the menu (
Tools > Java > Generate Code...
) - Select a base model (or package) that will be generated to Java.
- Select a folder where generated Java source files will be placed.
Belows are the rules to convert from UML model elements to Java source codes.
- converted to Java Package (as a folder).
- converted to Java Class. (as a separate
.java
file) visibility
to one of modifierspublic
,protected
,private
and none.isAbstract
property toabstract
modifier.isFinalSpecialization
andisLeaf
property tofinal
modifier.- Default constructor is generated.
- All contained types (UMLClass, UMLInterface, UMLEnumeration) are generated as inner type definition.
- Documentation property to JavaDoc comment.
- converted to Java Field.
visibility
property to one of modifierspublic
,protected
,private
and none.name
property to field identifier.type
property to field type.multiplicity
property to array type.isStatic
property tostatic
modifier.isLeaf
property tofinal
modifier.defaultValue
property to initial value.- Documentation property to JavaDoc comment.
- converted to Java Methods.
visibility
property to one of modifierspublic
,protected
,private
and none.name
property to method identifier.isAbstract
property toabstract
modifier.isStatic
property tostatic
modifier.- UMLParameter to Java Method Parameters.
- UMLParameter's name property to parameter identifier.
- UMLParameter's type property to type of parameter.
- UMLParameter with
direction
=return
to return type of method. When no return parameter,void
is used. - UMLParameter with
isReadOnly
=true
tofinal
modifier of parameter. - Documentation property to JavaDoc comment.
- converted to Java Interface. (as a separate
.java
file) visibility
property to one of modifierspublic
,protected
,private
and none.- Documentation property to JavaDoc comment.
- converted to Java Enum. (as a separate
.java
file) visibility
property to one of modifierspublic
,protected
,private
and none.- UMLEnumerationLiteral to literals of enum.
- converted to Java Field.
visibility
property to one of modifierspublic
,protected
,private
and none.name
property to field identifier.type
property to field type.- If
multiplicity
is one of0..*
,1..*
,*
, then collection type (java.util.List<>
whenisOrdered
=true
orjava.util.Set<>
) is used. defaultValue
property to initial value.- Documentation property to JavaDoc comment.
- converted to Java Extends (
extends
). - Allowed only for UMLClass to UMLClass, and UMLInterface to UMLInterface.
- converted to Java Implements (
implements
). - Allowed only for UMLClass to UMLInterface.
- Click the menu (
Tools > Java > Reverse Code...
) - Select a folder containing Java source files to be converted to UML model elements.
JavaReverse
model will be created in the Project.
Belows are the rules to convert from Java source code to UML model elements.
- converted to UMLPackage.
- converted to UMLClass.
- Class name to
name
property. - Type parameters to UMLTemplateParameter.
- Access modifier
public
,protected
andprivate
tovisibility
property. abstract
modifier toisAbstract
property.final
modifier toisLeaf
property.- Constructors to UMLOperation with stereotype
<<constructor>>
. - All contained types (UMLClass, UMLInterface, UMLEnumeration) are generated as inner type definition.
- JavaDoc comment to Documentation.
-
converted to UMLAttribute if "Use Association" is off in Preferences.
-
Field type to
type
property.- Primitive Types :
type
property has the primitive type name as string. T[]
(array),java.util.List<T>
,java.util.Set<T>
or its decendants:type
property refers toT
with multiplicity*
.T
(User-Defined Types) :type
property refers to theT
type.- Otherwise :
type
property has the type name as string.
- Primitive Types :
-
Access modifier
public
,protected
andprivate
tovisibility
property. -
static
modifier toisStatic
property. -
final
modifier toisLeaf
andisReadOnly
property. -
transient
modifier to a Tag withname="transient"
andchecked=true
. -
volatile
modifier to a Tag withname="volatile"
andchecked=true
. -
Initial value to
defaultValue
property. -
JavaDoc comment to Documentation.
-
converted to (Directed) UMLAssociation if "Use Association" is on in Preferences and there is a UML type element (UMLClass, UMLInterface, or UMLEnumeration) correspond to the field type.
-
Field type to
end2.reference
property.T[]
(array),java.util.List<T>
,java.util.Set<T>
or its decendants:reference
property refers toT
with multiplicity*
.T
(User-Defined Types) :reference
property refers to theT
type.- Otherwise : converted to UMLAttribute, not UMLAssociation.
-
Access modifier
public
,protected
andprivate
tovisibility
property. -
JavaDoc comment to Documentation.
- converted to UMLOperation.
- Type parameters to UMLTemplateParameter.
- Access modifier
public
,protected
andprivate
tovisibility
property. static
modifier toisStatic
property.abstract
modifier toisAbstract
property.final
modifier toisLeaf
property.synchronized
modifier toconcurrency="concurrent"
property.native
modifier to a Tag withname="native"
andchecked=true
.strictfp
modifier to a Tag withname="strictfp"
andchecked=true
.throws
clauses toraisedExceptions
property.- JavaDoc comment to Documentation.
- converted to UMLInterface.
- Class name to
name
property. - Type parameters to UMLTemplateParameter.
- Access modifier
public
,protected
andprivate
tovisibility
property. - JavaDoc comment to Documentation.
- converted to UMLEnumeration.
- Enum name to
name
property. - Type parameters to UMLTemplateParameter.
- Access modifier
public
,protected
andprivate
tovisibility
property. - Enum constants are converted to UMLEnumerationLiteral.
- JavaDoc comment to Documentation.
- converted to UMLClass with stereotype
<<annotationType>>
. - Annotation type elements to UMLOperation. (Default value to a Tag with
name="default"
). - JavaDoc comment to Documentation.
Licensed under the MIT license (see LICENSE file).