@@ -111,24 +111,22 @@ public static void mergeCurrentLimits(Collection<OperationalLimitsGroup> operati
111
111
112
112
// Build temporary limit from side 1 and 2
113
113
List <CurrentLimitsData > currentLimitsData1 = operationalLimitsGroups1 .stream ()
114
- .map (ElementUtils ::operationalLimitsGroupToMapDataCurrentLimits ).toList ();
114
+ .map (currentLimitsData ->
115
+ ElementUtils .operationalLimitsGroupToMapDataCurrentLimits (currentLimitsData , SIDE1 )).toList ();
115
116
ArrayList <CurrentLimitsData > currentLimitsData2 = new ArrayList <>(operationalLimitsGroups2 .stream ()
116
- .map (ElementUtils ::operationalLimitsGroupToMapDataCurrentLimits ).toList ());
117
+ .map (currentLimitsData ->
118
+ ElementUtils .operationalLimitsGroupToMapDataCurrentLimits (currentLimitsData , SIDE2 )).toList ());
117
119
118
120
// combine 2 sides in one list
119
121
120
122
// simple case : one of the arrays are empty
121
123
if (currentLimitsData2 .isEmpty () && !currentLimitsData1 .isEmpty ()) {
122
- for (CurrentLimitsData currentLimitsData : currentLimitsData1 ) {
123
- mergedLimitsData .add (copyCurrentLimitsData (currentLimitsData , SIDE1 ));
124
- }
124
+ mergedLimitsData .addAll (currentLimitsData1 );
125
125
build .accept (mergedLimitsData );
126
126
return ;
127
127
}
128
128
if (currentLimitsData1 .isEmpty () && !currentLimitsData2 .isEmpty ()) {
129
- for (CurrentLimitsData currentLimitsData : currentLimitsData2 ) {
130
- mergedLimitsData .add (copyCurrentLimitsData (currentLimitsData , SIDE2 ));
131
- }
129
+ mergedLimitsData .addAll (currentLimitsData2 );
132
130
build .accept (mergedLimitsData );
133
131
return ;
134
132
}
@@ -141,33 +139,31 @@ public static void mergeCurrentLimits(Collection<OperationalLimitsGroup> operati
141
139
CurrentLimitsData limitsData2 = l2 .get ();
142
140
// Only side one has limits
143
141
if (limitsData .hasLimits () && !limitsData2 .hasLimits ()) {
144
- mergedLimitsData .add (copyCurrentLimitsData ( limitsData , SIDE1 ) );
142
+ mergedLimitsData .add (limitsData );
145
143
// only side two has limits
146
144
} else if (limitsData2 .hasLimits () && !limitsData .hasLimits ()) {
147
- mergedLimitsData .add (copyCurrentLimitsData ( limitsData2 , SIDE2 ) );
145
+ mergedLimitsData .add (limitsData2 );
148
146
} else {
149
147
// both sides have limits and limits are equals
150
148
if (limitsData .limitsEquals (limitsData2 )) {
151
149
mergedLimitsData .add (copyCurrentLimitsData (limitsData , EQUIPMENT ));
152
150
// both side have limits and they are different : create 2 different limit sets
153
151
} else {
154
152
// Side 1
155
- mergedLimitsData .add (copyCurrentLimitsData ( limitsData , SIDE1 ) );
153
+ mergedLimitsData .add (limitsData );
156
154
// Side 2
157
- mergedLimitsData .add (copyCurrentLimitsData ( limitsData2 , SIDE2 ) );
155
+ mergedLimitsData .add (limitsData2 );
158
156
}
159
157
}
160
158
// remove processed limits from side 2
161
159
currentLimitsData2 .remove (l2 .get ());
162
160
} else {
163
- mergedLimitsData .add (copyCurrentLimitsData ( limitsData , SIDE1 ) );
161
+ mergedLimitsData .add (limitsData );
164
162
}
165
163
}
166
164
167
165
// add remaining limits from side 2
168
- for (CurrentLimitsData limitsData : currentLimitsData2 ) {
169
- mergedLimitsData .add (copyCurrentLimitsData (limitsData , SIDE2 ));
170
- }
166
+ mergedLimitsData .addAll (currentLimitsData2 );
171
167
172
168
if (!mergedLimitsData .isEmpty ()) {
173
169
build .accept (mergedLimitsData );
@@ -262,6 +258,10 @@ public static CurrentLimitsData toMapDataCurrentLimits(CurrentLimits limits) {
262
258
}
263
259
264
260
public static CurrentLimitsData operationalLimitsGroupToMapDataCurrentLimits (OperationalLimitsGroup operationalLimitsGroup ) {
261
+ return operationalLimitsGroupToMapDataCurrentLimits (operationalLimitsGroup , null );
262
+ }
263
+
264
+ public static CurrentLimitsData operationalLimitsGroupToMapDataCurrentLimits (OperationalLimitsGroup operationalLimitsGroup , CurrentLimitsData .Applicability applicability ) {
265
265
if (operationalLimitsGroup == null || operationalLimitsGroup .getCurrentLimits ().isEmpty ()) {
266
266
return null ;
267
267
}
@@ -278,6 +278,7 @@ public static CurrentLimitsData operationalLimitsGroupToMapDataCurrentLimits(Ope
278
278
builder .temporaryLimits (toMapDataTemporaryLimit (currentLimits .getTemporaryLimits ()));
279
279
containsLimitsData = true ;
280
280
}
281
+ builder .applicability (applicability );
281
282
282
283
return containsLimitsData ? builder .build () : null ;
283
284
}
0 commit comments