A package merge is a relationship between two packages, where generalization and redefinition are used to merge the content of the target (the general) package with the content of the source (the specific) package.
One important assumption of this merge is that equally named elements in different packages are based on the same concept.
package R {
class A {
y: int
}
class C
}
package P {
class A {
x: int
}
class B
B -> A#aList[*]
}
R ...> (merge) P
Merging rules (transformation rules)
The merge relationship is converted into a package import relationship, so private elements are not included in the package merge.
A new (empty) classifier is created in the source package (R) for each classifier in the target package (P) that does not exist in the source package. Then a generlization relationship for equelly named classifiers in the target package is defined between all the classifiers in the source package. All features of the superclassifier are redefined in the respective subclassifier.
Generalization relationships between classifiers in the target package are transferred to the corresponding classifiers in the source package.
A subpackage by the same name is created in the source package for each subpackage in the target package, unless it already exists. Subsequently, a package merge relationship is defined between the equally named packages of both the source and the target packages.
Package and element import relationships from the target package are transferred to the source package.
Finally, all elements from the target package that cannot be generalized are copied to the source package and equipped with the same relationships to the other elements.
package "R(Merge-Result)" {
class P::A { x:int }
class A {
y: int
x: int {redefines x}
}
class P::B
class B {
generalizes P::B
}
class B -> (redefines aList) A
class C
}
Generalization VS Package merge
Merging rules (transformation rules)
The merge relationship is converted into a package import relationship, so private elements are not included in the package merge.
A new (empty) classifier is created in the source package (R) for each classifier in the target package (P) that does not exist in the source package. Then a generlization relationship for equelly named classifiers in the target package is defined between all the classifiers in the source package. All features of the superclassifier are redefined in the respective subclassifier.
Generalization relationships between classifiers in the target package are transferred to the corresponding classifiers in the source package.
A subpackage by the same name is created in the source package for each subpackage in the target package, unless it already exists. Subsequently, a package merge relationship is defined between the equally named packages of both the source and the target packages.
Package and element import relationships from the target package are transferred to the source package.
Finally, all elements from the target package that cannot be generalized are copied to the source package and equipped with the same relationships to the other elements.