private void validate() {
		Assert.isTrue(modules != null && modules.size() > 0, "at least one module required");
		ModuleType inferredType = null;
		if (modules.size() == 1) {
			inferredType = modules.get(0).getType();
		}
		else {
			ModuleType firstType = modules.get(0).getType();
			ModuleType lastType = modules.get(modules.size() - 1).getType();
			boolean hasInput = firstType != ModuleType.source;
			boolean hasOutput = lastType != ModuleType.sink;
			if (hasInput && hasOutput) {
				inferredType = ModuleType.processor;
			}
			else if (hasInput) {
				inferredType = ModuleType.sink;
			}
			else if (hasOutput) {
				inferredType = ModuleType.source;
			}
		}
		Assert.isTrue(inferredType == this.getType(),
				"invalid composite module: inferred type=" + inferredType + ", stated type=" + this.getType());
	}
@author Mark Fisher
@author David Turanski
@author Gary Russell
spring-xd-module/src/main/java/org/springframework/xd/module/core/CompositeModule.java