@Test public void checkThatItDoesNotCreateDuplicatedAliasesNorThrow() { Network network = loadNetworkFromResourceFile("/aliasesDuplicationTest.uct"); UcteAliasesCreation.createAliases(network); assertNotNull(network.getIdentifiable("FFFFFF11 FFFFFF12 1")); assertNotNull(network.getIdentifiable("FFFFFF11 FFFFFF12 2")); assertNotNull(network.getIdentifiable("FFFFFF11 FFFFFF12 3")); assertNull(network.getIdentifiable("FFFFFF11 FFFFFF12 N/A")); assertNotNull(network.getIdentifiable("FFFFFF11 FFFFFF12 Unique")); }
public static void createAliases(Network network) { Set<String> duplicatedAliases = new HashSet<>(); network.getBranchStream().forEach(branch -> { if (branch instanceof TieLine) { TieLine tieLine = (TieLine) branch; tieLine.addAlias(tieLine.getHalf1().getId()); tieLine.addAlias(tieLine.getHalf2().getId()); addHalfElementNameAliases(tieLine, duplicatedAliases); } addElementNameAlias(branch, duplicatedAliases); }); network.getSwitchStream().forEach(switchEl -> addElementNameAlias(switchEl, duplicatedAliases)); network.getDanglingLineStream().forEach(dl -> addElementNameAlias(dl, duplicatedAliases)); }
UcteAliasesCreation { public static void createAliases(Network network) { Set<String> duplicatedAliases = new HashSet<>(); network.getBranchStream().forEach(branch -> { if (branch instanceof TieLine) { TieLine tieLine = (TieLine) branch; tieLine.addAlias(tieLine.getHalf1().getId()); tieLine.addAlias(tieLine.getHalf2().getId()); addHalfElementNameAliases(tieLine, duplicatedAliases); } addElementNameAlias(branch, duplicatedAliases); }); network.getSwitchStream().forEach(switchEl -> addElementNameAlias(switchEl, duplicatedAliases)); network.getDanglingLineStream().forEach(dl -> addElementNameAlias(dl, duplicatedAliases)); } }
UcteAliasesCreation { public static void createAliases(Network network) { Set<String> duplicatedAliases = new HashSet<>(); network.getBranchStream().forEach(branch -> { if (branch instanceof TieLine) { TieLine tieLine = (TieLine) branch; tieLine.addAlias(tieLine.getHalf1().getId()); tieLine.addAlias(tieLine.getHalf2().getId()); addHalfElementNameAliases(tieLine, duplicatedAliases); } addElementNameAlias(branch, duplicatedAliases); }); network.getSwitchStream().forEach(switchEl -> addElementNameAlias(switchEl, duplicatedAliases)); network.getDanglingLineStream().forEach(dl -> addElementNameAlias(dl, duplicatedAliases)); } private  UcteAliasesCreation(); }
UcteAliasesCreation { public static void createAliases(Network network) { Set<String> duplicatedAliases = new HashSet<>(); network.getBranchStream().forEach(branch -> { if (branch instanceof TieLine) { TieLine tieLine = (TieLine) branch; tieLine.addAlias(tieLine.getHalf1().getId()); tieLine.addAlias(tieLine.getHalf2().getId()); addHalfElementNameAliases(tieLine, duplicatedAliases); } addElementNameAlias(branch, duplicatedAliases); }); network.getSwitchStream().forEach(switchEl -> addElementNameAlias(switchEl, duplicatedAliases)); network.getDanglingLineStream().forEach(dl -> addElementNameAlias(dl, duplicatedAliases)); } private  UcteAliasesCreation(); static void createAliases(Network network); }
UcteAliasesCreation { public static void createAliases(Network network) { Set<String> duplicatedAliases = new HashSet<>(); network.getBranchStream().forEach(branch -> { if (branch instanceof TieLine) { TieLine tieLine = (TieLine) branch; tieLine.addAlias(tieLine.getHalf1().getId()); tieLine.addAlias(tieLine.getHalf2().getId()); addHalfElementNameAliases(tieLine, duplicatedAliases); } addElementNameAlias(branch, duplicatedAliases); }); network.getSwitchStream().forEach(switchEl -> addElementNameAlias(switchEl, duplicatedAliases)); network.getDanglingLineStream().forEach(dl -> addElementNameAlias(dl, duplicatedAliases)); } private  UcteAliasesCreation(); static void createAliases(Network network);  }