java powerdesigner_powerdesigner 生成JAVA类

  • Post author:
  • Post category:java


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 %_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 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 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 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



版权声明:本文为weixin_42364780原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。