Skip to content

Commit

Permalink
merge interface
Browse files Browse the repository at this point in the history
  • Loading branch information
Pauline Jean-Marie committed Nov 10, 2023
1 parent 1165439 commit efe13ca
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
package com.powsybl.ampl.converter;

import com.powsybl.ampl.converter.version.AmplExportVersion;
import com.powsybl.ampl.converter.version.AmplExportVersionImpl;

import java.util.Objects;

Expand Down Expand Up @@ -52,13 +51,13 @@ public String getLabel() {
private boolean twtSplitShuntAdmittance;

public AmplExportConfig(ExportScope exportScope, boolean exportXNodes, ExportActionType actionType) {
this(exportScope, exportXNodes, actionType, false, false, AmplExportVersionImpl.V1_LEGACY);
this(exportScope, exportXNodes, actionType, false, false, AmplExportVersion.V1_LEGACY);
}

public AmplExportConfig(ExportScope exportScope, boolean exportXNodes, ExportActionType actionType,
boolean exportRatioTapChangerVoltageTarget, boolean twtSplitShuntAdmittance) {
this(exportScope, exportXNodes, actionType, exportRatioTapChangerVoltageTarget, twtSplitShuntAdmittance,
AmplExportVersionImpl.V1_LEGACY);
AmplExportVersion.V1_LEGACY);
}

public AmplExportConfig(ExportScope exportScope, boolean exportXNodes, ExportActionType actionType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import com.google.auto.service.AutoService;
import com.powsybl.ampl.converter.version.AmplExportVersion;
import com.powsybl.ampl.converter.version.AmplExportVersionImpl;
import com.powsybl.commons.config.PlatformConfig;
import com.powsybl.commons.datasource.DataSource;
import com.powsybl.commons.parameters.Parameter;
Expand Down Expand Up @@ -59,8 +58,8 @@ public class AmplExporter implements Exporter {

private static final Parameter EXPORT_VERSION_PARAMETER = new Parameter(EXPORT_VERSION, ParameterType.STRING,
"The version of the export.",
AmplExportVersionImpl.V1_LEGACY.name(),
Arrays.stream(AmplExportVersionImpl.values()).map(Enum::name).collect(Collectors.toList()));
AmplExportVersion.V1_LEGACY.name(),
Arrays.stream(AmplExportVersion.values()).map(Enum::name).collect(Collectors.toList()));

private static final List<Parameter> STATIC_PARAMETERS = List.of(EXPORT_SCOPE_PARAMETER, EXPORT_XNODES_PARAMETER,
EXPORT_ACTION_TYPE_PARAMETER, EXPORT_RATIOTAPCHANGER_VT_PARAMETER, TWT_SPLIT_SHUNT_ADMITTANCE_PARAMETER,
Expand Down Expand Up @@ -97,7 +96,7 @@ public void export(Network network, Properties parameters, DataSource dataSource
boolean exportRatioTapChangerVoltageTarget = Parameter.readBoolean(getFormat(), parameters, EXPORT_RATIOTAPCHANGER_VT_PARAMETER, defaultValueConfig);
boolean twtSplitShuntAdmittance = Parameter.readBoolean(getFormat(), parameters,
TWT_SPLIT_SHUNT_ADMITTANCE_PARAMETER, defaultValueConfig);
AmplExportVersion exportVersion = AmplExportVersionImpl.valueOf(
AmplExportVersion exportVersion = AmplExportVersion.valueOf(
Parameter.readString(getFormat(), parameters, EXPORT_VERSION_PARAMETER, defaultValueConfig));

AmplExportConfig config = new AmplExportConfig(scope, exportXnodes, actionType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,24 @@
/**
* @author Nicolas Pierre {@literal <nicolas.pierre at artelys.com>}
*/
public interface AmplExportVersion {
interface Factory {
public enum AmplExportVersion {
/**
* Legacy export
*/
V1_LEGACY(BasicAmplExporter.getFactory());

public interface Factory {
AmplColumnsExporter create(AmplExportConfig config, Network network, StringToIntMapper<AmplSubset> mapper,
int variantIndex, int faultNum, int actionNum);
}

Factory getColumnsExporter();
private final Factory factory;

AmplExportVersion(Factory factory) {
this.factory = factory;
}

public Factory getColumnsExporter() {
return factory;
}
}

This file was deleted.

0 comments on commit efe13ca

Please sign in to comment.