
|
If you were logged in you would be able to see more operations.
|
|
|
|
In my project I have analyzed, that the extension "String org::fornax::cartridges::uml2::javabasic::m2t::Helper::fqName(uml::Type type)" takes a lot of time at generation. I implement this extension in Java and have performance improvement of 20% in our projects. I have attached a patch for this improvement, feel free to modify my code.
|
|
Description
|
In my project I have analyzed, that the extension "String org::fornax::cartridges::uml2::javabasic::m2t::Helper::fqName(uml::Type type)" takes a lot of time at generation. I implement this extension in Java and have performance improvement of 20% in our projects. I have attached a patch for this improvement, feel free to modify my code. |
Show » |
|
So here are my code changes in Helper.ext and Helper.java:
Helper.ext:
>>>
String fqName (uml::Type type, String prefix) :
JAVA org.fornax.cartridges.uml2.javabasic.Helper.getFqName(org.eclipse.uml2.uml.Type, java.lang.String);
String fqName (uml::Type type) :
JAVA org.fornax.cartridges.uml2.javabasic.Helper.getFqName(org.eclipse.uml2.uml.Type);
<<<
Helper.java
>>>
/**
* Calculates the full qualified name of the given type
*
* @param type
* The <code>org.eclipse.uml2.uml.Type</code> to calculate the
* full qualified name for
* @return The full qualified name as <code>java.lang.String</code>
*/
public static String getFqName(Type type) {
return getFqName(type, "");
}
/**
* Calculates the full qualified name of the given type and appends a prefix
*
* @param type
* The <code>org.eclipse.uml2.uml.Type</code> to calculate the
* full qualified name for
* @param prefix
* The prefix as <code>java.lang.String</code> which should be
* appended
* @return The full qualified name as <code>java.lang.String</code>
*/
public static String getFqName(Type type, String prefix) {
if (type == null) {
return "void";
}
String pt = prefix + type.getName();
String[] primitiveTypes = { "boolean", "byte", "char", "double",
"float", "int", "long", "short", "void" };
for (int i = 0; i < primitiveTypes.length; i++) {
if (primitiveTypes[i].equals(pt)) {
return pt;
}
}
if (pt.equals("Boolean")) {
return "java.lang.Boolean";
}
if (pt.equals("Byte")) {
return "java.lang.Byte";
}
if (pt.equals("Character")) {
return "java.lang.Character";
}
if (pt.equals("Collection")) {
return "java.util.Collection";
}
if (pt.equals("Date")) {
return "java.util.Date";
}
if (pt.equals("Decimal")) {
return "java.math.BigDecimal";
}
if (pt.equals("Double")) {
return "java.lang.Double";
}
if (pt.equals("Float")) {
return "java.lang.Float";
}
if (pt.equals("Int")) {
return "java.lang.Integer";
}
if (pt.equals("Integer")) {
return "java.lang.Integer";
}
if (pt.equals("List")) {
return "java.util.List";
}
if (pt.equals("Long")) {
return "java.lang.Long";
}
if (pt.equals("Set")) {
return "java.util.Set";
}
if (pt.equals("Short")) {
return "java.lang.Short";
}
if (pt.equals("String")) {
return "java.lang.String";
}
String fqn = getFQNPackageName(type);
if (fqn != "") {
return fqn + "." + pt;
} else {
return pt;
}
}
<<<