11/*******************************************************************************
22 * SysML 2 Pilot Implementation
3- * Copyright (c) 2024 Model Driven Solutions, Inc.
3+ * Copyright (c) 2024, 2025 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
2121
2222package org .omg .sysml .adapter ;
2323
24+ import org .omg .sysml .lang .sysml .DecisionNode ;
25+ import org .omg .sysml .lang .sysml .Feature ;
26+ import org .omg .sysml .lang .sysml .MergeNode ;
2427import org .omg .sysml .lang .sysml .Namespace ;
2528import org .omg .sysml .lang .sysml .SuccessionAsUsage ;
2629import org .omg .sysml .lang .sysml .TransitionUsage ;
2730import org .omg .sysml .util .ElementUtil ;
31+ import org .omg .sysml .util .FeatureUtil ;
32+ import org .omg .sysml .util .UsageUtil ;
2833
2934public class SuccessionAsUsageAdapter extends SuccessionAdapter {
3035
@@ -47,9 +52,42 @@ protected void addContextFeaturingType() {
4752 }
4853 }
4954
55+ @ Override
56+ public void addDefaultGeneralType () {
57+ super .addDefaultGeneralType ();
58+ addDecisionNodeOutgoingSuccessionSpecialization ();
59+ addMergeNodeIncomingSuccessionSpecialization ();
60+ }
61+
62+ /**
63+ * @satisfies checkDecisionNodeOutgoingSuccessionSpecialization
64+ *
65+ * TODO: Update checkDecisionNodeOutgoingSuccessionSpecialization
66+ *
67+ * OCL refers to MergePerformance::outgoingHBLink rather than DecisionPerformance::outgoingHBLink.
68+ * See SYSML21-306
69+ */
70+ protected void addDecisionNodeOutgoingSuccessionSpecialization () {
71+ SuccessionAsUsage succession = getTarget ();
72+ // Note: Use utility method to get source feature, to avoid infinite recursion.
73+ Feature sourceFeature = UsageUtil .getSourceOf (succession );
74+ if (sourceFeature instanceof DecisionNode ) {
75+ addImplicitGeneralType (getSpecializationEClass (),
76+ FeatureUtil .chainFeatures (sourceFeature , (Feature )getLibraryType (getDefaultSupertype ("decision" ))));
77+ }
78+ }
79+
5080 /**
51- * TODO: checkDecisionNodeOutgoingSuccessionSpecialization
52- * TODO: checkMergeNodeIncomingSuccessionSpecialization
81+ * @satisfies checkMergeNodeIncomingSuccessionSpecialization
5382 */
83+ protected void addMergeNodeIncomingSuccessionSpecialization () {
84+ SuccessionAsUsage succession = getTarget ();
85+ // Note: Use utility method to get target feature, to avoid infinite recursion.
86+ Feature targetFeature = UsageUtil .getTargetOf (succession );
87+ if (targetFeature instanceof MergeNode ) {
88+ addImplicitGeneralType (getSpecializationEClass (),
89+ FeatureUtil .chainFeatures (targetFeature , (Feature )getLibraryType (getDefaultSupertype ("merge" ))));
90+ }
91+ }
5492
5593}
0 commit comments