Conversation
This lead to an error if datatypes where imported indirectly.
- new language features - javadoc
There was a problem hiding this comment.
Pull request overview
Fixes incorrect attribute identity handling for data type instances when the same data type is brought into a model multiple times via indirect imports, so attribute slots can be looked up by logical identity (owner + name) rather than object identity.
Changes:
- Switch
MDataTypeValueStateattribute-slot storage fromIdentityHashMaptoHashMapto enable equality-based key lookup. - Add/modernize
MAttributeequality support by providing ahashCode()implementation consistent withequals(...). - Extend the
Timeexample data type with abefore(other: Time)operation.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| use-core/src/main/resources/examples/Documentation/Imports/Time.use | Adds a before operation to the Time data type example. |
| use-core/src/main/java/org/tzi/use/uml/sys/MDataTypeValueState.java | Uses HashMap for attribute slots to avoid identity-based lookup failures across repeated imports. |
| use-core/src/main/java/org/tzi/use/uml/mm/MAttribute.java | Adds hashCode() (and minor Javadoc/equals modernization) so attributes behave correctly as hash keys. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Just chaining implies is not enough Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Added test with different imports. Before the fix, invariant "businessHours" failed with output "N/A"
…tributes' into bugs/identitymap_for_datatype_attributes
There was a problem hiding this comment.
Pull request overview
Fixes datatype attribute slot lookup when the same datatype is imported multiple times (e.g., via indirect imports), so attribute access works based on semantic equality rather than object identity.
Changes:
- Switch datatype value state attribute-slot storage from
IdentityHashMaptoHashMap. - Add
hashCode()toMAttributeto align with existingequals()semantics (owner + name), enabling correct hashed lookups. - Add a new shell integration test (with indirect-imported Date/Time/DateTime datatypes) to reproduce/guard the scenario; update import documentation example to include
Time::before.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| use-gui/src/it/resources/testfiles/shell/t133_imports.use | New model exercising indirect imports and datatype attribute navigation (time.hour, etc.). |
| use-gui/src/it/resources/testfiles/shell/t133_imports.in | New shell script asserting the scenario executes and invariants pass. |
| use-gui/src/it/resources/testfiles/shell/imports/t133_import_time.use | New Time datatype used by the indirect-import test. |
| use-gui/src/it/resources/testfiles/shell/imports/t133_import_datetime.use | New DateTime datatype that indirectly imports Date and Time. |
| use-gui/src/it/resources/testfiles/shell/imports/t133_import_date.use | New Date datatype used by the indirect-import test. |
| use-core/src/main/resources/examples/Documentation/Imports/Time.use | Documentation example extended with Time::before. |
| use-core/src/main/java/org/tzi/use/uml/sys/MDataTypeValueState.java | Use HashMap for datatype attribute slots to allow equality-based lookup. |
| use-core/src/main/java/org/tzi/use/uml/mm/MAttribute.java | Add hashCode() consistent with equals() for reliable hashed map/set behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ) | ||
|
|
||
| getEasterSunday() : Date = | ||
| // Following Gauss algorithm to calculate eastern |
When datatypes are imported mutiple times via indirect imports attributes cannot be identified by identity, only by their attributes owner and name.