1717import lombok .experimental .FieldNameConstants ;
1818import lombok .experimental .SuperBuilder ;
1919
20+ import java .util .Collection ;
2021import java .util .Iterator ;
2122import java .util .Optional ;
2223import java .util .UUID ;
@@ -84,7 +85,7 @@ protected static Double getPatlLimit(LimitViolation limitViolation, Network netw
8485 return null ;
8586 }
8687
87- Optional <CurrentLimits > currentLimits = limitViolationSide . name (). equals ( TwoSides . ONE . name ()) ? branch .getCurrentLimits1 () : branch . getCurrentLimits2 ( );
88+ Optional <CurrentLimits > currentLimits = branch .getCurrentLimits ( limitViolationSide . toTwoSides () );
8889 if (currentLimits .isPresent ()) {
8990 return currentLimits .get ().getPermanentLimit ();
9091 }
@@ -109,16 +110,17 @@ private static LoadingLimits.TemporaryLimit getNextTemporaryLimit(Branch<?> bran
109110 return null ;
110111 }
111112
112- Optional <CurrentLimits > currentLimits = limitViolationSide . name (). equals ( TwoSides . ONE . name ()) ? branch .getCurrentLimits1 () : branch . getCurrentLimits2 ( );
113+ Optional <CurrentLimits > currentLimits = branch .getCurrentLimits ( limitViolationSide . toTwoSides () );
113114 if (currentLimits .isEmpty ()) {
114115 return null ;
115116 }
116117
118+ Collection <LoadingLimits .TemporaryLimit > temporaryLimits = currentLimits .get ().getTemporaryLimits ();
117119 if (limitName .equals (LimitViolationUtils .PERMANENT_LIMIT_NAME )) {
118- return currentLimits . get (). getTemporaryLimits () .stream ().findFirst ().orElse (null );
120+ return temporaryLimits .stream ().findFirst ().orElse (null );
119121 }
120122
121- Iterator <LoadingLimits .TemporaryLimit > temporaryLimitIterator = currentLimits . get (). getTemporaryLimits () .iterator ();
123+ Iterator <LoadingLimits .TemporaryLimit > temporaryLimitIterator = temporaryLimits .iterator ();
122124 while (temporaryLimitIterator .hasNext ()) {
123125 LoadingLimits .TemporaryLimit currentTemporaryLimit = temporaryLimitIterator .next ();
124126 if (currentTemporaryLimit .getName ().equals (limitViolation .getLimitName ())) {
0 commit comments