Papyrus static profile Java code issue with "*" or "unlimited value" handling [message #1837469] |
Sun, 31 January 2021 01:38 |
Deniz Eren Messages: 68 Registered: March 2014 |
Member |
|
|
Problem found regarding UML::UnlimitedNatural handling being mixed with UML::Integer in such a way that the "*" or "unlimited value" isn't being handled corrected in the Java generated OCL expressions.
Attached is tar file ValidationProblem6.tar.gz containing the example static profile wrapped in a Git repo called "com.validationproblem.profile".
Testing was done with 2020-06 Eclipse release - Papyrus 4.8.0 (version installed when installing Papyrus SysML 1.6 Feature through the Marketplace).
In the stereotype Stereotype1 I have added properties:
- +u: UnlimitedNatural[1] - free for user to set after applying stereotype
- +/isUnlimited: Boolean[1] - derived property with OCL expression "self.u = *"
- +/copy_u: UnlimitedNatural[1] - derived property with OCL expression "self.u"
When I generate Java code using genmodel with setting "Use Delegates" I get the Java code generated as shown in the attached profile code and pasted here in the ticket below.
As you can see the generated functions getU returns 'u' as an 'int' literal, which means the UML notion of "*" or "unlimited value" is lost! Doesn't seem to be represented even?
You can also see the function setU set by 'int' again same problem/limitation.
Function isUnlimited performs the OCL expression "self.u = *" check by first casting the value of u to "int" via getU
ValueUtil however seems to have an unlimited value implementation - so casting to "int" first seems problematic to me:
public static final @NonNull UnlimitedValue UNLIMITED_VALUE = new UnlimitedValueImpl();
In isUnlimited generated function I even get a Java build error for trying to assign a UnlimitedNaturalValue using an IntegerValue:
final /*@NonInvalid*/ UnlimitedNaturalValue BOXED_u = ValueUtil.integerValueOf(u);
It seems UML::UnlimitedNatural handling is mixed with UML::Integer in such a way that the "*" or "unlimited value" isn't being handled corrected in the Java generated OCL expressions.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public int getU() {
return u;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void setU(int newU) {
int oldU = u;
u = newU;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ValidationProblemPackage.STEREOTYPE1__U, oldU, u));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean isUnlimited() {
/**
* self.u = *
*/
final /*@NonInvalid*/ int u = this.getU();
final /*@NonInvalid*/ UnlimitedNaturalValue BOXED_u = ValueUtil.integerValueOf(u);
final /*@NonInvalid*/ boolean eq = BOXED_u.equals(ValueUtil.UNLIMITED_VALUE);
return eq;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public int getCopy_u() {
/**
* self.u
*/
final /*@NonInvalid*/ int u = this.getU();
return u;
}
[Updated on: Sun, 31 January 2021 01:41] Report message to a moderator
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04041 seconds