File tree Expand file tree Collapse file tree
org.omg.sysml/src/org/omg/sysml/adapter Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -34,9 +34,8 @@ public AttributeUsage getTarget() {
3434 }
3535
3636 @ Override
37- public void doTransform () {
38- super .doTransform ();
39- addDefaultMultiplicity ();
37+ protected boolean isAddMultiplicity () {
38+ return isAddDefaultMultiplicity ();
4039 }
4140
4241}
Original file line number Diff line number Diff line change @@ -45,8 +45,8 @@ protected String getDefaultSupertype() {
4545 }
4646
4747 @ Override
48- protected void addDefaultMultiplicity () {
49-
48+ protected boolean isAddMultiplicity () {
49+ return getTarget (). isEnd ();
5050 }
5151
5252 @ Override
Original file line number Diff line number Diff line change 11/*******************************************************************************
22 * SysML 2 Pilot Implementation
3- * Copyright (c) 2021 Model Driven Solutions, Inc.
3+ * Copyright (c) 2021, 2024 Model Driven Solutions, Inc.
44 *
55 * This program is free software: you can redistribute it and/or modify
66 * it under the terms of the GNU Lesser General Public License as published by
@@ -56,10 +56,11 @@ public boolean isSubitem() {
5656 (owningType instanceof ItemDefinition || owningType instanceof ItemUsage );
5757 }
5858
59+ // Transformation
60+
5961 @ Override
60- public void doTransform () {
61- super .doTransform ();
62- addDefaultMultiplicity ();
62+ protected boolean isAddMultiplicity () {
63+ return isAddDefaultMultiplicity ();
6364 }
6465
6566}
Original file line number Diff line number Diff line change @@ -36,6 +36,8 @@ public PortUsageAdapter(PortUsage element) {
3636 public PortUsage getTarget () {
3737 return (PortUsage )super .getTarget ();
3838 }
39+
40+ // Implicit Generalization
3941
4042 @ Override
4143 protected String getDefaultSupertype () {
@@ -58,10 +60,11 @@ public boolean isSubport() {
5860 return target .isComposite () && (owningType instanceof PortDefinition || owningType instanceof PortUsage );
5961 }
6062
63+ // Transformation
64+
6165 @ Override
62- public void doTransform () {
63- super .doTransform ();
64- addDefaultMultiplicity ();
66+ protected boolean isAddMultiplicity () {
67+ return isAddDefaultMultiplicity ();
6568 }
6669
6770}
Original file line number Diff line number Diff line change @@ -115,15 +115,27 @@ public void addDefaultGeneralType() {
115115
116116 // Transformation
117117
118- protected void addDefaultMultiplicity () {
118+ // Used to check for default multiplicity for AttributeUsages, ItemUsages and PortUsages.
119+ protected boolean isAddDefaultMultiplicity () {
119120 Usage target = getTarget ();
120- if (target .getOwningType () != null &&
121- target .getOwnedSubsetting ().stream ().
122- map (Subsetting ::getSubsettedFeature ).
123- filter (f ->f != null ).
124- map (FeatureUtil ::getBasicFeatureOf ).
125- noneMatch (f ->f != null && f .getOwningType () != null )) {
126- TypeUtil .addMultiplicityTo (target );
121+ return target .isEnd () ||
122+ target .getOwningType () != null &&
123+ target .getOwnedSubsetting ().stream ().
124+ map (Subsetting ::getSubsettedFeature ).
125+ filter (f ->f != null ).
126+ map (FeatureUtil ::getBasicFeatureOf ).
127+ noneMatch (f ->f != null && f .getOwningType () != null );
128+ }
129+
130+ // Multiplicity of 1..1 is always the default for an end usage.
131+ protected boolean isAddMultiplicity () {
132+ return getTarget ().isEnd ();
133+ }
134+
135+ @ Override
136+ public void addAdditionalMembers () {
137+ if (isAddMultiplicity ()) {
138+ TypeUtil .addMultiplicityTo (getTarget ());
127139 }
128140 }
129141
You can’t perform that action at this time.
0 commit comments