Skip to content

Commit

Permalink
Factorize code
Browse files Browse the repository at this point in the history
Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
  • Loading branch information
flo-dup committed Feb 3, 2023
1 parent f588c26 commit cbfab40
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ protected void writeBlackBoxModel(XMLStreamWriter writer, DynaWaltzContext conte
writer.writeStartElement(DYN_URI, "blackBoxModel");
writeDynamicAttributes(writer, context);
writer.writeAttribute("staticId", staticId);
MacroStaticReference.writeMacroStaticRef(writer, getLib());
if (!getVarsMapping().isEmpty()) {
MacroStaticReference.writeMacroStaticRef(writer, getLib());
}
writer.writeEndElement();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,11 @@
import com.powsybl.iidm.network.Bus;
import com.powsybl.iidm.network.Line;

import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import static com.powsybl.dynawaltz.xml.DynaWaltzXmlConstants.DYN_URI;

public class StandardLine extends AbstractBlackBoxModel implements LineModel {

private final String sidePostfix;
Expand All @@ -39,14 +35,6 @@ public List<VarMapping> getVarsMapping() {
return Collections.emptyList();
}

@Override
public void write(XMLStreamWriter writer, DynaWaltzContext context) throws XMLStreamException {
writer.writeStartElement(DYN_URI, "blackBoxModel");
writeDynamicAttributes(writer, context);
writer.writeAttribute("staticId", getStaticId().orElse(null));
writer.writeEndElement();
}

@Override
public List<VarConnection> getVarConnectionsWith(Model connected) {
if (connected instanceof BusModel) {
Expand Down

0 comments on commit cbfab40

Please sign in to comment.