@Test public void testChosenTwoNamingStrategies() { NamingStrategy namingStrategy = UcteExporter.findNamingStrategy("Default", ImmutableList.of(new DefaultNamingStrategy(), new OtherNamingStrategy())); assertEquals("Default", namingStrategy.getName()); namingStrategy = UcteExporter.findNamingStrategy("OtherNamingStrategy", ImmutableList.of(new DefaultNamingStrategy(), new OtherNamingStrategy())); assertEquals("OtherNamingStrategy", namingStrategy.getName()); }
static NamingStrategy findNamingStrategy(String name, List<NamingStrategy> namingStrategies) { Objects.requireNonNull(namingStrategies); if (namingStrategies.size() == 1 && name == null) { return namingStrategies.get(0); } else { if (namingStrategies.size() > 1 && name == null) { List<String> namingStrategyNames = namingStrategies.stream().map(NamingStrategy::getName).collect(Collectors.toList()); throw new PowsyblException("Several naming strategy implementations found (" + namingStrategyNames + "), you must add properties to select the implementation"); } return namingStrategies.stream() .filter(ns -> ns.getName().equals(name)) .findFirst() .orElseThrow(() -> new PowsyblException("NamingStrategy '" + name + "' not found")); } }
UcteExporter implements Exporter { static NamingStrategy findNamingStrategy(String name, List<NamingStrategy> namingStrategies) { Objects.requireNonNull(namingStrategies); if (namingStrategies.size() == 1 && name == null) { return namingStrategies.get(0); } else { if (namingStrategies.size() > 1 && name == null) { List<String> namingStrategyNames = namingStrategies.stream().map(NamingStrategy::getName).collect(Collectors.toList()); throw new PowsyblException("Several naming strategy implementations found (" + namingStrategyNames + "), you must add properties to select the implementation"); } return namingStrategies.stream() .filter(ns -> ns.getName().equals(name)) .findFirst() .orElseThrow(() -> new PowsyblException("NamingStrategy '" + name + "' not found")); } } }
UcteExporter implements Exporter { static NamingStrategy findNamingStrategy(String name, List<NamingStrategy> namingStrategies) { Objects.requireNonNull(namingStrategies); if (namingStrategies.size() == 1 && name == null) { return namingStrategies.get(0); } else { if (namingStrategies.size() > 1 && name == null) { List<String> namingStrategyNames = namingStrategies.stream().map(NamingStrategy::getName).collect(Collectors.toList()); throw new PowsyblException("Several naming strategy implementations found (" + namingStrategyNames + "), you must add properties to select the implementation"); } return namingStrategies.stream() .filter(ns -> ns.getName().equals(name)) .findFirst() .orElseThrow(() -> new PowsyblException("NamingStrategy '" + name + "' not found")); } } UcteExporter();  UcteExporter(PlatformConfig platformConfig); }
UcteExporter implements Exporter { static NamingStrategy findNamingStrategy(String name, List<NamingStrategy> namingStrategies) { Objects.requireNonNull(namingStrategies); if (namingStrategies.size() == 1 && name == null) { return namingStrategies.get(0); } else { if (namingStrategies.size() > 1 && name == null) { List<String> namingStrategyNames = namingStrategies.stream().map(NamingStrategy::getName).collect(Collectors.toList()); throw new PowsyblException("Several naming strategy implementations found (" + namingStrategyNames + "), you must add properties to select the implementation"); } return namingStrategies.stream() .filter(ns -> ns.getName().equals(name)) .findFirst() .orElseThrow(() -> new PowsyblException("NamingStrategy '" + name + "' not found")); } } UcteExporter();  UcteExporter(PlatformConfig platformConfig); @Override String getFormat(); @Override String getComment(); @Override void export(Network network, Properties parameters, DataSource dataSource); }
UcteExporter implements Exporter { static NamingStrategy findNamingStrategy(String name, List<NamingStrategy> namingStrategies) { Objects.requireNonNull(namingStrategies); if (namingStrategies.size() == 1 && name == null) { return namingStrategies.get(0); } else { if (namingStrategies.size() > 1 && name == null) { List<String> namingStrategyNames = namingStrategies.stream().map(NamingStrategy::getName).collect(Collectors.toList()); throw new PowsyblException("Several naming strategy implementations found (" + namingStrategyNames + "), you must add properties to select the implementation"); } return namingStrategies.stream() .filter(ns -> ns.getName().equals(name)) .findFirst() .orElseThrow(() -> new PowsyblException("NamingStrategy '" + name + "' not found")); } } UcteExporter();  UcteExporter(PlatformConfig platformConfig); @Override String getFormat(); @Override String getComment(); @Override void export(Network network, Properties parameters, DataSource dataSource); static final String NAMING_STRATEGY; }