private Topology createAdHocTopologyFromSuitableOptions ( SuitableOptions appInfoSuitableOptions ) { Topology topology = new Topology ( ) ; TopologyElement current = null ; TopologyElement previous = null ; for ( String moduleName : appInfoSuitableOptions . getStringIterator ( ) ) { if ( current == null ) { // first element treated. None of them needs to point at it current = new TopologyElement ( moduleName ) ; topology . addModule ( current ) ; } else { // There were explored already other modules previous = current ; current = new TopologyElement ( moduleName ) ; previous . addElementCalled ( current ) ; topology . addModule ( current ) ; } } return topology ; }
Later it will be better an exception than a weird result .