private void assertModuleUpdatability(String name, ModuleType type, boolean force) {
		ModuleDefinition definition = registry.findDefinition(name, type);
		if (definition != null) {
			if (!force) {
				throw new ModuleAlreadyExistsException(name, type);
			} else {
				Set<String> dependents = this.dependencyRepository.find(name, type);
				if (!dependents.isEmpty()) {
					throw new DependencyException("Cannot force update module %2$s:%1$s because it is used by %3$s", name, type, dependents);
				} else {
					// Perform an eager deletion, taking care of module flavor change.
					// Also, this catches cases when we're trying to replace a read-only module
					if (!registry.delete(definition)) {
						throw new ModuleAlreadyExistsException("There is already a module named '%s' with type '%s', and it cannot be updated", name, type);
					}
				}
			}
		}
	}
Throws an exception if either one of the following is true:<ul>
    <li>a module with the given name and type already exists and force is {@code false}</li>
    <li>force if {@true} but the module is in use (by a stream or composed module)</li>
</ul>

<p>Also, will actually delete the already existing definition in case of an update,
even though it would be overwritten by a registry, to cover the cases where a composed
module is being replaced by a simple uploaded module, and <i>vice versa</i>.</p>

@param name name of the module we're trying to update/create
@param type type of the module we're trying to update/create
@param force whether to attempt to force update if the module already exists
spring-xd-dirt/src/main/java/org/springframework/xd/dirt/module/support/ModuleDefinitionService.java