1.对类添加JavaDoc注释
Language->Edit Current Object Language...
Java::Profile/Class/Templates/javaDoc修改代码如下:
[%ActualComment%/n/n]/
[%@since%/n]/
[%@deprecated%/n]/
[%@author%/n]/
[%@version%/n]/
[%@see%/n]/
.if (%GenOptions.GenerateOID%)
[@pdOid %.L:ObjectID%/n]/
.endif
[%@misc%/n]/
[%Name%]
2.对本类属性添加注释
Language->Edit Current Object Language...
Java::Profile/Classifier/Templates/attributes修改代码如下:
.foreach_item(Attributes)
.if ((%@1% == all) or (%Visibility% == %@1%)) and (%Derived% == false)
.if (%isRoleAMigrated%)
[%MigratedAssociation.roleAMigrateDefinition%/n]
.elsif (%isRoleBMigrated%)
[%MigratedAssociation.roleBMigrateDefinition%/n]
.else
//[%Name%]
[%definition%/n]
.endif
.endif
.next
3.对相关联类添加注释
Language->Edit Current Object Language...
Java::Profile/Association/Templates/roleAMigrateFromAssoc修改代码如下:
.// Migrate from an association
.if (%RoleANavigability%)
.set_value(_attributeCode, %roleACode%, new)
.set_object(_association, , new)
.set_object(_class, ClassB, new)
.set_value(_migrateAttributeCode, false, new)
.if (%hasAttribute% == false)
//[%ClassA.Name%]
%roleAMigrateDefinition%
.endif(/n)
.endif
Language->Edit Current Object Language...
Java::Profile/Association/Templates/roleBMigrateFromAssoc修改代码如下:
.// Migrate from an association
.if (%RoleBNavigability%)
.set_value(_attributeCode, %roleBCode%, new)
.set_object(_association, , new)
.set_object(_class, ClassA, new)
.set_value(_migrateAttributeCode, false, new)
.if (%hasAttribute% == false)
//[%ClassB.Name%]
%roleBMigrateDefinition%
.endif(/n)
.endif
4.在Iterator后加入泛型
Language->Edit Current Object Language...
Java::Profile/Association/Templates/Helpers/Migrate/accessorsMany修改代码如下:
.if (%implInterface%)
.// Get collection
.set_value(_operationName, get%.FU:roleName%, new)
.set_value(_operationSignature, get%.FU:roleName%, new)
.set_value(_memberName, %roleName%, new)
.if (%endClassHasOperation% == false)
/** @pdGenerated default getter */
public %implInterface% %_operationName%() /
{
if (%_memberName% == null)
%_memberName% = new %implClass%();
return %_memberName%;
}
.endif(/n/n)
.// Get iterator
.set_value(_operationName, getIterator%.FU:roleName%, new)
.set_value(_operationSignature, getIterator%.FU:roleName%, new)
.set_value(_memberName, %roleName%, new)
.if (%endClassHasOperation% == false)
/** @pdGenerated default iterator getter */
public java.util.Iterator<%Classifier.qualifiedCode%> %_operationName%() /
{
if (%_memberName% == null)
%_memberName% = new %implClass%();
return %_memberName%.iterator();
}
.endif(/n/n)
.// Set collection
.set_value(_operationName, set%.FU:roleName%, new)
.set_value(_operationSignature, set%.FU:roleName%@%implInterface%, new)
.set_value(_paramName, new%.FU:roleName%, new)
.set_value(_memberName, %roleName%, new)
.if (%endClassHasOperation% == false)
/** @pdGenerated default setter
* @param %_paramName% */
public void %_operationName%(%implInterface% %_paramName%) /
{
removeAll%.FU:roleName%();
for (java.util.Iterator<%Classifier.qualifiedCode%> iter = %_paramName%.iterator(); iter.hasNext();)
add%.FU:roleName%((%Classifier.qualifiedCode%)iter.next());
}
.endif(/n/n)
.// Add object
.set_value(_operationName, add%.FU:roleName%, new)
.set_value(_operationSignature, add%.FU:roleName%@%Classifier.qualifiedCode%, new)
.set_value(_paramName, new%.FU:Classifier.Code%, new)
.set_value(_memberName, %roleName%, new)
.if (%endClassHasOperation% == false)
/** @pdGenerated default add
* @param %_paramName% */
public void %_operationName%(%Classifier.qualifiedCode% %_paramName%) /
{
if (%_paramName% == null)
return;
if (this.%_memberName% == null)
this.%_memberName% = new %implClass%();
if (!this.%_memberName%.contains(%_paramName%))/n
.if (%endNavigability%) and (%endMultiple% == false)
{
this.%_memberName%.add(%_paramName%);
%_paramName%.set%.FU:endRoleName%(this);
}
.elsif (%endNavigability%) and (%endMultiple%) and (%endClassHasImplementation%)
{
this.%_memberName%.add(%_paramName%);
%_paramName%.add%.FU:endRoleName%(this);
}
.else
this.%_memberName%.add(%_paramName%);
.endif(/n)
}
.endif(/n/n)
.// Remove object
.set_value(_operationName, remove%.FU:roleName%, new)
.set_value(_operationSignature, remove%.FU:roleName%@%Classifier.qualifiedCode%, new)
.set_value(_paramName, old%.FU:Classifier.Code%, new)
.set_value(_memberName, %roleName%, new)
.if (%endClassHasOperation% == false)
/** @pdGenerated default remove
* @param %_paramName% */
public void %_operationName%(%Classifier.qualifiedCode% %_paramName%) /
{
if (%_paramName% == null)
return;
if (this.%_memberName% != null)
if (this.%_memberName%.contains(%_paramName%))/n
.if (%endNavigability%) and (%endMultiple% == false)
{
this.%_memberName%.remove(%_paramName%);
%_paramName%.set%.FU:endRoleName%((%EndClassifier.qualifiedCode%)null);
}
.elsif (%endNavigability%) and (%endMultiple%) and (%endClassHasImplementation%)
{
this.%_memberName%.remove(%_paramName%);
%_paramName%.remove%.FU:endRoleName%(this);
}
.else
this.%_memberName%.remove(%_paramName%);
.endif(/n)
}
.endif(/n/n)
.// Remove all objects
.set_value(_operationName, removeAll%.FU:roleName%, new)
.set_value(_operationSignature, removeAll%.FU:roleName%, new)
.set_value(_memberName, %roleName%, new)
.set_value(_tempObjName, old%.FU:Classifier.Code%, new)
.if (%endClassHasOperation% == false)
/** @pdGenerated default removeAll */
public void %_operationName%() /
{
if (%_memberName% != null)/n
.if (%endNavigability%) and (%endMultiple% == false)
{
%Classifier.qualifiedCode% %_tempObjName%;
for (java.util.Iterator<%Classifier.qualifiedCode%> iter = getIterator%.FU:roleName%(); iter.hasNext();)
{
%_tempObjName% = (%Classifier.qualifiedCode%)iter.next();
iter.remove();
%_tempObjName%.set%.FU:endRoleName%((%EndClassifier.qualifiedCode%)null);
}
}
.elsif (%endNavigability%) and (%endMultiple%) and (%endClassHasImplementation%)
{
%Classifier.qualifiedCode% %_tempObjName%;
for (java.util.Iterator<%Classifier.qualifiedCode%> iter = getIterator%.FU:roleName%(); iter.hasNext();)
{
%_tempObjName% = (%Classifier.qualifiedCode%)iter.next();
iter.remove();
%_tempObjName%.remove%.FU:endRoleName%(this);
}
}
.else
%_memberName%.clear();
.endif(/n)
}
.endif(/n)
.else
.if (%isGenAssocDefaultAccessors%)
.// Default accessors
.// Get array
.set_value(_operationName, get%.FU:roleName%, new)
.set_value(_operationSignature, get%.FU:roleName%, new)
.set_value(_memberName, %roleName%, new)
.if (%endClassHasOperation% == false)
/** @pdGenerated default getter */
public %Classifier.qualifiedCode%/[/] %_operationName%() /
{
return %_memberName%;
}
.endif(/n/n)
.// Set array
.set_value(_operationName, set%.FU:roleName%, new)
.set_value(_operationSignature, set%.FU:roleName%@%Classifier.qualifiedCode%#, new)
.set_value(_paramName, new%.FU:roleName%, new)
.set_value(_memberName, %roleName%, new)
.if (%endClassHasOperation% == false)
/** @pdGenerated default setter
* @param %_paramName% */
public void %_operationName%(%Classifier.qualifiedCode%/[/] %_paramName%) /
{
this.%_memberName% = %_paramName%;
}
.endif(/n/n)
.endif
.endif
5.去除pdOid注释
Java::Generation/Options/GenerateOID,Value值设置为No