com.powsybl.loadflow.validation.CandidateComputations Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of powsybl-loadflow-validation Show documentation
Show all versions of powsybl-loadflow-validation Show documentation
A tool to check the load-flow results
The newest version!
/**
* Copyright (c) 2018, 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.loadflow.validation;
import com.google.common.base.Suppliers;
import com.google.common.collect.ImmutableList;
import java.util.List;
import java.util.Optional;
import java.util.ServiceLoader;
import java.util.function.Supplier;
/**
* Provides access to the list of known candidate computations.
*
* @author Sylvain Leclerc {@literal }
*/
public final class CandidateComputations {
//Lazy initialization of the list of computations
private static final Supplier> COMPUTATIONS =
Suppliers.memoize(() -> ImmutableList.copyOf(ServiceLoader.load(CandidateComputation.class, CandidateComputations.class.getClassLoader())));
private CandidateComputations() {
}
/**
* Get the list of all known candidate computations implementations.
* The returned list is immutable.
*/
public static List getComputations() {
return COMPUTATIONS.get();
}
/**
* Get the list of all known candidate computations names.
* The returned list is immutable.
*/
public static List getComputationsNames() {
return getComputations().stream().map(CandidateComputation::getName).toList();
}
/**
* Get a candidate computation by its name.
*/
public static Optional getComputation(String name) {
return getComputations().stream().filter(c -> c.getName().equals(name)).findFirst();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy