code: public void replaceElementsIndexes(TopologyElement element, int toIndex) {
        int targetIndex = modules.indexOf(element);
        if (log.isDebugEnabled()) {
           if (modules == null) {
              log.warn("Modules in topology points to NULL");
           }
           if (element == null) {
              log.warn("Element to search in topology points to NULL");
           }
           log.debug("The topology consists of " + modules.size() + " modules. Replacing index " + toIndex + " with "
                 + targetIndex + ". The element name whose index was searched was " + element.getName()
                 + "and the topology was composed of modules: " + toString());
        }
        TopologyElement replaced = modules.set(toIndex, element);
        modules.set(targetIndex, replaced);
     }
docs: @param element
  @param toIndex
  Swaps the elements indexes. "Element" gets "toIndex" index and
  the previous element with index "toIndex" gets the previous
  index of "element"