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

com.powsybl.action.ial.dsl.modification.ScriptNetworkModification Maven / Gradle / Ivy

/**
 * Copyright (c) 2017, 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/.
 * SPDX-License-Identifier: MPL-2.0
 */
package com.powsybl.action.ial.dsl.modification;

import com.powsybl.commons.report.ReportNode;
import com.powsybl.computation.ComputationManager;
import com.powsybl.iidm.modification.AbstractNetworkModification;
import com.powsybl.iidm.modification.topology.NamingStrategy;
import com.powsybl.iidm.network.Network;
import groovy.lang.Closure;

import java.util.Objects;

/**
 * @author Geoffroy Jamgotchian {@literal }
 */
public class ScriptNetworkModification extends AbstractNetworkModification {

    private final Closure script;

    public ScriptNetworkModification(Closure script) {
        this.script = Objects.requireNonNull(script);
    }

    @Override
    public String getName() {
        return "ScriptNetworkModification";
    }

    public Closure getScript() {
        return script;
    }

    @Override
    public void apply(Network network, NamingStrategy namingStrategy, boolean throwException,
                      ComputationManager computationManager, ReportNode reportNode) {
        script.call(network, computationManager);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy