Overview
Basic modeling documentation can be found at the AndroMDA site AndroMDA - Getting started Java (3.2)
Usage differences from AndoMDA are:
- Array type usage
- Enumeration stereotype is replaced by TypesafeEnum stereotype.
Project pom.xml properties usage:\
overrideWsPom
false/overrideWsPom
dataSourceName
jdbc/k2DS,jdbc/configDS/dataSourceName
xsdExcludePatterns
net/sf/jivalo/ws,net/sf/jivalo/sample/ws/xsdExcludePatterns
xsdExcludeCompilePatterns
net/sf/jivalo/sample/ws/xsdExcludeCompilePatterns
wsUnpackArtifacts
net.sf.jivalo.ws:sample@schema/wsUnpackArtifacts
\
TypesafeEnum
stereotype usage:
Following example is inspired by Sun's Java guide to Enums
- Create class named Planet Use stereotype TypesafeEnum. Leave @jivalo.enum.behavior.constants tag to false.
- Create private attributes mass and radius. Use AndroMDA datatype double
- Create public static attributes MERCURY, VENUS, EARTH. Use stereotype TypesafeEnumConstant. Use AndroMDA datatype String. Set MERCURY @jivalo.enum.init tag to 3.303e+23, 2.4397e6
. Set VENUS @jivalo.enum.init tag to 4.869e+24, 6.0518e6
. Set EARTH @jivalo.enum.init tag to 5.976e+24, 6.37814e6
and also set EARTH default value to Earth
.
- Create public methods mass, radius, surfaceGravity and surfaceWeight. Use stereotype TypesafeEnumMethod. Use AndroMDA datatype double for all return and parameter types. Set mass @jivalo.enum.init tag to return mass;
. Set radius @jivalo.enum.init tag to return radius;
. Set surfaceGravity @jivalo.enum.init tag to return G * mass / (radius * radius);
. Set surfaceWeight @jivalo.enum.init tag to return otherMass * surfaceGravity();
and add parameter otherMass.
Results Planet.java
class.
Basic usage is to just create TypesafeEnumConstant attributes with type String and that it. Even with this simpliest use case you can modify value by setting attributes default value as desired.
One scenario is that Enumeration value type in database is different than string (or if string value is different than name). In that case you must set TypesafeEnumConstant attributes type to desired (e.g int or String ...) and add additional private attribute with type String.
- Create class named SimpleType Use stereotype TypesafeEnum. Leave @jivalo.enum.behavior.constants tag to false.
- Create private attributes name. Use AndroMDA datatype string
- Create public static attributes TYPE1, TYPE2. Use stereotype TypesafeEnumConstant. Use AndroMDA datatype int. Set TYPE1 @jivalo.enum.init tag to "Type 1"
and also set TYPE1 default value to 1
. Set TYPE2 @jivalo.enum.init tag to "Type 2"
and also set TYPE2 default value to 2
.
Results SimpleType.java
class.