Bug 581882 - [pivot] Rationalize numeric *ValueImpl as just *Value
Summary: [pivot] Rationalize numeric *ValueImpl as just *Value
Status: NEW
Alias: None
Product: OCL
Classification: Modeling
Component: Core (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 10
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: OCL Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 509309
  Show dependency tree
 
Reported: 2023-05-01 09:13 EDT by Ed Willink CLA
Modified: 2023-05-02 11:18 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ed Willink CLA 2023-05-01 09:13:27 EDT
The Value classes currently emulate EMF with Value interfaces and ValueImpl implementations. It washoped that Values.genmodel would generate them consistently, but it has never worked.

The numeric ValueImpl classes extend the non-interface java.lang.Number and so their corresponding Value interfaces fail to assign to Number without a cast.

Simplify so that there are just numeric *Value classes that inherit from java.lang.NUmber; interfaces such as Unlimited just for mis-ins.
Comment 1 Ed Willink CLA 2023-05-01 09:19:52 EDT
The current implementation relies on declaring

Integer as java.lang.Number in Pivot.ecore for Java gen

Integer as org.eclipse.ocl.pivot.values.IntegerValue in OCLstdlib for validation.

Using org.eclipse.ocl.pivot.values.IntegerValue consistently requires bogus casts.
Comment 2 Ed Willink CLA 2023-05-02 11:18:25 EDT
(In reply to Ed Willink from comment #1)
> Using org.eclipse.ocl.pivot.values.IntegerValue consistently requires bogus
> casts.

This problem should go awy with no *Impl so we can live with it for now.

A few surprises cause limited but nont quite trvial inconvenience.

Changing Import.xmiidVersion to IntegerValue hits requires internal int-based code to change and inelegantly costs memory albeit pretty trivial overall. Perhaps a ShortInteger class should allow small integers.

Much more significantly all the code based on CollectionType lower/upper has to be revised, but beneficially. Once both API and metamodel use Value all the conversion to use int/long vanish and the confusing between "*", -1, UNLIMITED, UNLIMITED_VALUE can vanish.

There are many Boolean[1]-valued properties and operation returns that really do not want to convert from "boolean" to "@Nullable Boolean", so we definitely want an EBoolean as well as Boolean. Conversion to EBoolean can be automated during the synthesis of Pivot.ecore from Pivot.oclas since there is a clear [1]/[?] multiplicity.