/** * Constructs a new {@code PortReAdder} holding the given {@link ConnectedSelfLoopComponent}s * given. * * @param components The {@link ConnectedSelfLoopComponent}s to be part of this PortReAdder. */ PortReadder(final List<ConnectedSelfLoopComponent> components) { // Initialize the mapping. As the mapping is static, this needs to be done on every new run. for (LoopSide side : LoopSide.values()) { LISTS_OF_COMPONENTS.put(side, new ArrayList<ConnectedSelfLoopComponent>()); } // First: group the components according to their loopSide for (final ConnectedSelfLoopComponent component : components) { allHiddenPorts.addAll(component.getHidablePorts()); if (component.getNonLoopPorts().isEmpty()) { LISTS_OF_COMPONENTS.get(component.getLoopSide()).add(component); } else { withNonSelfLoop.add(component); } } // Second: sort the collections of components // (in revered order, biggest first) for (List<ConnectedSelfLoopComponent> list : LISTS_OF_COMPONENTS.values()) { Collections.sort(list, loopSorter); } // ports on the NW-border need to be reversed, again. Collections.reverse(LISTS_OF_COMPONENTS.get(LoopSide.NW)); }
static { for (LoopSide side : LoopSide.values()) { LISTS_OF_COMPONENTS.put(side, null); } }