com.powsybl.sld.cgmes.dl.iidm.extensions.NodeDiagramData Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of powsybl-single-line-diagram-cgmes-iidm-extensions Show documentation
Show all versions of powsybl-single-line-diagram-cgmes-iidm-extensions Show documentation
A collection of IIDM extensions to store CGMES-DL data
/**
* Copyright (c) 2019, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package com.powsybl.sld.cgmes.dl.iidm.extensions;
import com.powsybl.commons.extensions.AbstractExtension;
import com.powsybl.iidm.network.Bus;
import com.powsybl.iidm.network.BusbarSection;
import com.powsybl.iidm.network.Identifiable;
import java.util.*;
/**
*
* @author Massimo Ferraro {@literal }
*/
public class NodeDiagramData> extends AbstractExtension {
static final String NAME = "node-diagram-data";
public class NodeDiagramDataDetails {
private DiagramPoint point1;
private DiagramPoint point2;
public DiagramPoint getPoint1() {
return point1;
}
public void setPoint1(DiagramPoint point1) {
this.point1 = Objects.requireNonNull(point1);
}
public DiagramPoint getPoint2() {
return point2;
}
public void setPoint2(DiagramPoint point2) {
this.point2 = Objects.requireNonNull(point2);
}
}
private Map diagramsDetails = new HashMap<>();
private NodeDiagramData(T identifiable) {
super(identifiable);
}
public NodeDiagramData(BusbarSection busbar) {
this((T) busbar);
}
public NodeDiagramData(Bus bus) {
this((T) bus);
}
@Override
public String getName() {
return NAME;
}
public void addData(String diagramName, NodeDiagramDataDetails nodeDetails) {
Objects.requireNonNull(diagramName);
Objects.requireNonNull(nodeDetails);
diagramsDetails.put(diagramName, nodeDetails);
}
public NodeDiagramDataDetails getData(String diagramName) {
Objects.requireNonNull(diagramName);
return diagramsDetails.get(diagramName);
}
public List getDiagramsNames() {
return new ArrayList<>(diagramsDetails.keySet());
}
public static NodeDiagramData getOrCreateDiagramData(Bus bus) {
NodeDiagramData nodeDiagramData = bus.getExtension(NodeDiagramData.class);
if (nodeDiagramData == null) {
nodeDiagramData = new NodeDiagramData<>(bus);
}
return nodeDiagramData;
}
public static NodeDiagramData getOrCreateDiagramData(BusbarSection busbar) {
NodeDiagramData nodeDiagramData = busbar.getExtension(NodeDiagramData.class);
if (nodeDiagramData == null) {
nodeDiagramData = new NodeDiagramData<>(busbar);
}
return nodeDiagramData;
}
}