AbstractAddMemoryBlockCmd createAddBlockCommand() {
		String source = "";
		switch (blockType) {
			case BIT_MAPPED:
				return new AddBitMappedMemoryBlockCmd(blockName, comment, source, startAddr, length,
					isRead, isWrite, isExecute, isVolatile, baseAddr, isOverlay);
			case BYTE_MAPPED:
				ByteMappingScheme byteMappingScheme =
					new ByteMappingScheme(schemeDestByteCount, schemeSrcByteCount);
				return new AddByteMappedMemoryBlockCmd(blockName, comment, source, startAddr,
					length, isRead, isWrite, isExecute, isVolatile, baseAddr, byteMappingScheme,
					isOverlay);
			case DEFAULT:
				return createNonMappedMemoryBlock(source);
			default:
				throw new AssertException("Encountered unexpected block type: " + blockType);
		}
	}
Model to manage adding a memory block.
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/memory/AddBlockModel.java