All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.farao_community.farao.data.crac_impl.TopologicalActionAdderImpl Maven / Gradle / Ivy

There is a newer version: 5.0.0
Show newest version
/*
 * Copyright (c) 2021, 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.farao_community.farao.data.crac_impl;

import com.farao_community.farao.data.crac_api.NetworkElement;
import com.farao_community.farao.data.crac_api.network_action.ActionType;
import com.farao_community.farao.data.crac_api.network_action.NetworkActionAdder;
import com.farao_community.farao.data.crac_api.network_action.TopologicalAction;
import com.farao_community.farao.data.crac_api.network_action.TopologicalActionAdder;

import static com.farao_community.farao.data.crac_impl.AdderUtils.assertAttributeNotNull;

/**
 * @author Baptiste Seguinot {@literal }
 */
public class TopologicalActionAdderImpl implements TopologicalActionAdder {

    private NetworkActionAdderImpl ownerAdder;
    private String networkElementId;
    private String networkElementName;
    private ActionType actionType;

    TopologicalActionAdderImpl(NetworkActionAdderImpl ownerAdder) {
        this.ownerAdder = ownerAdder;
    }

    @Override
    public TopologicalActionAdder withNetworkElement(String networkElementId) {
        this.networkElementId = networkElementId;
        return this;
    }

    @Override
    public TopologicalActionAdder withNetworkElement(String networkElementId, String networkElementName) {
        this.networkElementId = networkElementId;
        this.networkElementName = networkElementName;
        return this;
    }

    @Override
    public TopologicalActionAdder withActionType(ActionType actionType) {
        this.actionType = actionType;
        return this;
    }

    @Override
    public NetworkActionAdder add() {

        assertAttributeNotNull(networkElementId, "TopologicalAction", "network element", "withNetworkElement()");
        assertAttributeNotNull(actionType, "TopologicalAction", "action type", "withActionType()");

        NetworkElement networkElement;
        networkElement = this.ownerAdder.getCrac().addNetworkElement(networkElementId, networkElementName);

        TopologicalAction topologicalAction = new TopologicalActionImpl(networkElement, actionType);
        ownerAdder.addElementaryAction(topologicalAction);
        return ownerAdder;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy