private ModuleType determineTypeFromNamedChannels(ModuleDescriptor.Builder builder, int lastIndex,
			ParsingContext parsingContext) {
		// Should this fail for composed module too?
		if (parsingContext == ParsingContext.job
				&& (builder.getSourceChannelName() != null || builder.getSinkChannelName() != null)) {
			throw new RuntimeException("TODO");
		}
		ModuleType type = null;
		String moduleName = builder.getModuleName();
		int index = builder.getIndex();
		if (builder.getSourceChannelName() != null) { // preceded by >, so not a source
			if (index == lastIndex) { // this is the final module of the stream
				if (builder.getSinkChannelName() != null) { // but followed by >, so not a sink
					type = ModuleType.processor;
				}
				else { // final module and no >, so IS a sink
					type = ModuleType.sink;
				}
			}
			else { // not final module, must be a processor
				type = ModuleType.processor;
			}
		}
		else if (builder.getSinkChannelName() != null) { // followed by >, so not a sink
			if (index == 0) { // first module in a stream, and not preceded by >, so IS a source
				type = ModuleType.source;
			}
			else { // not first module, and followed by >, so not a source or sink
				type = ModuleType.processor;
			}
		}
		return (type == null) ? null : resolveModuleType(moduleName, type);
	}
Attempt to guess the type of a module given the presence of named channels
references at the start or end of the stream definition.

@return module type, or null if no named channels were present
spring-xd-dirt/src/main/java/org/springframework/xd/dirt/stream/XDStreamParser.java