@@ -32,10 +32,23 @@ public abstract class AbstractBranchImpl<T extends Branch<T>, U extends BranchAt
32
32
33
33
private ConnectablePositionImpl <T > connectablePositionExtension ;
34
34
35
+ private CurrentLimits currentLimits1 ;
36
+
37
+ private CurrentLimits currentLimits2 ;
38
+
35
39
protected AbstractBranchImpl (NetworkObjectIndex index , Resource <U > resource ) {
36
40
super (index , resource );
37
41
terminal1 = TerminalImpl .create (index , new BranchToInjectionAttributesAdapter (this , resource .getAttributes (), true ), getBranch ());
38
42
terminal2 = TerminalImpl .create (index , new BranchToInjectionAttributesAdapter (this , resource .getAttributes (), false ), getBranch ());
43
+
44
+ if (resource .getAttributes ().getCurrentLimits1 () != null ) {
45
+ currentLimits1 = new CurrentLimitsImpl (this , resource .getAttributes ().getCurrentLimits1 ());
46
+ }
47
+
48
+ if (resource .getAttributes ().getCurrentLimits2 () != null ) {
49
+ currentLimits1 = new CurrentLimitsImpl (this , resource .getAttributes ().getCurrentLimits2 ());
50
+ }
51
+
39
52
ConnectablePositionAttributes cpa1 = resource .getAttributes ().getPosition1 ();
40
53
ConnectablePositionAttributes cpa2 = resource .getAttributes ().getPosition2 ();
41
54
if (cpa1 != null && cpa2 != null ) {
@@ -106,15 +119,22 @@ public void notifyUpdate(String attribute, Object oldValue, Object newValue, boo
106
119
}
107
120
108
121
@ Override
109
- public void setCurrentLimits (Branch .Side side , CurrentLimitsAttributes currentLimits ) {
110
- if (side == Branch .Side .ONE ) {
111
- CurrentLimitsAttributes oldCurrentLimits = resource .getAttributes ().getCurrentLimits1 ();
112
- resource .getAttributes ().setCurrentLimits1 (currentLimits );
113
- index .notifyUpdate (this , "currentLimits1" , oldCurrentLimits , currentLimits );
114
- } else if (side == Branch .Side .TWO ) {
115
- CurrentLimitsAttributes oldCurrentLimits = resource .getAttributes ().getCurrentLimits2 ();
116
- resource .getAttributes ().setCurrentLimits2 (currentLimits );
117
- index .notifyUpdate (this , "currentLimits2" , oldCurrentLimits , currentLimits );
122
+ public void setCurrentLimitsAttributes (Branch .Side side , CurrentLimitsAttributes currentLimits ) {
123
+ switch (side ) {
124
+ case ONE : {
125
+ CurrentLimitsAttributes oldCurrentLimits = resource .getAttributes ().getCurrentLimits1 ();
126
+ resource .getAttributes ().setCurrentLimits1 (currentLimits );
127
+ index .notifyUpdate (this , "currentLimits1" , oldCurrentLimits , currentLimits );
128
+ break ;
129
+ }
130
+ case TWO : {
131
+ CurrentLimitsAttributes oldCurrentLimits = resource .getAttributes ().getCurrentLimits2 ();
132
+ resource .getAttributes ().setCurrentLimits2 (currentLimits );
133
+ index .notifyUpdate (this , "currentLimits2" , oldCurrentLimits , currentLimits );
134
+ break ;
135
+ }
136
+ default :
137
+ throw new IllegalStateException ();
118
138
}
119
139
}
120
140
@@ -137,22 +157,36 @@ public void remove() {
137
157
public CurrentLimits getCurrentLimits (Branch .Side side ) {
138
158
switch (side ) {
139
159
case ONE :
140
- return getCurrentLimits1 () ;
160
+ return this . currentLimits1 ;
141
161
case TWO :
142
- return getCurrentLimits2 () ;
162
+ return this . currentLimits2 ;
143
163
default :
144
164
throw new IllegalStateException ();
145
165
}
146
166
}
147
167
148
168
@ Override
149
169
public CurrentLimits getCurrentLimits1 () {
150
- return resource . getAttributes (). getCurrentLimits1 () != null ? new CurrentLimitsImpl ( this , resource . getAttributes (). getCurrentLimits1 ()) : null ;
170
+ return currentLimits1 ;
151
171
}
152
172
153
173
@ Override
154
174
public CurrentLimits getCurrentLimits2 () {
155
- return resource .getAttributes ().getCurrentLimits2 () != null ? new CurrentLimitsImpl (this , resource .getAttributes ().getCurrentLimits2 ()) : null ;
175
+ return currentLimits2 ;
176
+ }
177
+
178
+ @ Override
179
+ public void setCurrentLimits (Branch .Side side , CurrentLimits currentLimits ) {
180
+ switch (side ) {
181
+ case ONE :
182
+ this .currentLimits1 = currentLimits ;
183
+ break ;
184
+ case TWO :
185
+ this .currentLimits2 = currentLimits ;
186
+ break ;
187
+ default :
188
+ throw new IllegalStateException ();
189
+ }
156
190
}
157
191
158
192
@ Override
0 commit comments