Code review comment: could we move that logic somewhere else?

Code under review:
public QuarkusCommandOutcome execute(QuarkusCommandInvocation invocation) throws QuarkusCommandException {
        final ExtensionCatalog extensionCatalog = invocation.getExtensionsCatalog();
        final Set<String> extensionsQuery = invocation.getValue(ProjectGenerator.EXTENSIONS, Collections.emptySet());

        final Properties quarkusProps = ToolsUtils.readQuarkusProperties(extensionCatalog);
        quarkusProps.forEach((k, v) -> {
            String name = k.toString().replace("-", "_");
            if (!invocation.hasValue(name)) {
                invocation.setValue(k.toString().replace("-", "_"), v.toString());
            }
        });

        
        final String className = invocation.getStringValue(CLASS_NAME);
        final String pkgName = invocation.getStringValue(PACKAGE_NAME);
        final String groupId = invocation.getStringValue(PROJECT_GROUP_ID);
        if (pkgName == null) {
            if (className != null && className.contains(".")) {
                final int idx = className.lastIndexOf('.');
                invocation.setValue(PACKAGE_NAME, className.substring(0, idx));
                invocation.setValue(CLASS_NAME, className.substring(idx + 1));
            } else if (groupId != null) {
                invocation.setValue(PACKAGE_NAME, groupId.replace("-", ".").replace("_", "."));
            }
        }

        final List<ArtifactCoords> extensionsToAdd = computeCoordsFromQuery(invocation, extensionsQuery);
        if (extensionsToAdd == null) {
            throw new QuarkusCommandException("Failed to create project because of invalid extensions");
        }

        List<ArtifactCoords> boms = Collections.emptyList();
        ArtifactCoords bom = null;
        final ElementCatalog ec = (ElementCatalog) extensionCatalog.getMetadata().get("element-catalog");
        if (ec != null) {
            
            
            final Extension quarkusCore = invocation.getExtensionsCatalog().getExtensions().stream()
                    .filter(e -> e.getArtifact().getArtifactId().equals("quarkus-core")).findFirst().get();
            if (quarkusCore == null) {
                throw new QuarkusCommandException("Failed to locate quarkus-core in the extension catalog");
            }
            final List<String> eKeys;
            if (extensionsToAdd.isEmpty()) {
                eKeys = Collections.singletonList(
                        quarkusCore.getArtifact().getGroupId() + ":" + quarkusCore.getArtifact().getArtifactId());
            } else {
                eKeys = extensionsToAdd.stream().map(e -> e.getGroupId() + ":" + e.getArtifactId())
                        .collect(Collectors.toList());
                eKeys.add(quarkusCore.getArtifact().getGroupId() + ":" + quarkusCore.getArtifact().getArtifactId());
            }
            boms = ElementCatalogBuilder.getBoms(ec, eKeys);
            final Iterator<ArtifactCoords> i = boms.iterator();
            while (i.hasNext()) {
                final ArtifactCoords next = i.next();
                
                
                if (next.getArtifactId().equals("quarkus-bom")) {
                    bom = next;
                    i.remove();
                    break;
                }
            }
        } else {
            bom = extensionCatalog.getBom();
        }
        if (bom == null) {
            throw new QuarkusCommandException("The platform BOM is missing");
        }

        invocation.setValue(BOM_GROUP_ID, bom.getGroupId());
        invocation.setValue(BOM_ARTIFACT_ID, bom.getArtifactId());
        invocation.setValue(BOM_VERSION, bom.getVersion());
        invocation.setValue(QUARKUS_VERSION, extensionCatalog.getQuarkusCoreVersion());

        try {
            Map<String, Object> platformData = new HashMap<>();
            if (extensionCatalog.getMetadata().get("maven") != null) {
                platformData.put("maven", extensionCatalog.getMetadata().get("maven"));
            }
            if (extensionCatalog.getMetadata().get("gradle") != null) {
                platformData.put("gradle", extensionCatalog.getMetadata().get("gradle"));
            }
            final QuarkusCodestartProjectInput input = QuarkusCodestartProjectInput.builder()
                    .addPlatforms(boms)
                    .addExtensions(extensionsToAdd)
                    .buildTool(invocation.getQuarkusProject().getBuildTool())
                    .example(invocation.getValue(EXAMPLE))
                    .noCode(invocation.getValue(NO_CODE, false))
                    .addCodestarts(invocation.getValue(EXTRA_CODESTARTS, Collections.emptySet()))
                    .noBuildToolWrapper(invocation.getValue(NO_BUILDTOOL_WRAPPER, false))
                    .noDockerfiles(invocation.getValue(NO_DOCKERFILES, false))
                    .addData(platformData)
                    .addData(LegacySupport.convertFromLegacy(invocation.getValues()))
                    .putData(APP_CONFIG.key(), invocation.getValue(APP_CONFIG.key(), Collections.emptyMap()))
                    .messageWriter(invocation.log())
                    .build();
            invocation.log().info("-----------");
            if (!extensionsToAdd.isEmpty()) {
                invocation.log().info("selected extensions: \n"
                        + extensionsToAdd.stream().map(e -> "- " + e.getGroupId() + ":" + e.getArtifactId() + "\n")
                                .collect(Collectors.joining()));
            }

            final QuarkusCodestartCatalog catalog = QuarkusCodestartCatalog
                    .fromExtensionsCatalog(invocation.getQuarkusProject().getExtensionsCatalog(),
                            invocation.getQuarkusProject().getCodestartResourceLoaders());
            final CodestartProjectDefinition projectDefinition = catalog.createProject(input);
            projectDefinition.generate(invocation.getQuarkusProject().getProjectDirPath());
            invocation.log()
                    .info("\n-----------\n" + MessageIcons.OK_ICON + " "
                            + projectDefinition.getRequiredCodestart(CodestartType.PROJECT).getName()
                            + " project has been successfully generated in:\n--> "
                            + invocation.getQuarkusProject().getProjectDirPath().toString() + "\n-----------");

        } catch (IOException e) {
            throw new QuarkusCommandException("Failed to create project: " + e.getMessage(), e);
        }

        return QuarkusCommandOutcome.success();
    }

Line commented on: while (i.hasNext()) {

Revised code:
public QuarkusCommandOutcome execute(QuarkusCommandInvocation invocation) throws QuarkusCommandException {
        final ExtensionCatalog extensionCatalog = invocation.getExtensionsCatalog();
        final Set<String> extensionsQuery = invocation.getValue(ProjectGenerator.EXTENSIONS, Collections.emptySet());

        final Properties quarkusProps = ToolsUtils.readQuarkusProperties(extensionCatalog);
        quarkusProps.forEach((k, v) -> {
            String name = k.toString().replace("-", "_");
            if (!invocation.hasValue(name)) {
                invocation.setValue(k.toString().replace("-", "_"), v.toString());
            }
        });

        
        final String className = invocation.getStringValue(CLASS_NAME);
        final String pkgName = invocation.getStringValue(PACKAGE_NAME);
        final String groupId = invocation.getStringValue(PROJECT_GROUP_ID);
        if (pkgName == null) {
            if (className != null && className.contains(".")) {
                final int idx = className.lastIndexOf('.');
                invocation.setValue(PACKAGE_NAME, className.substring(0, idx));
                invocation.setValue(CLASS_NAME, className.substring(idx + 1));
            } else if (groupId != null) {
                invocation.setValue(PACKAGE_NAME, groupId.replace("-", ".").replace("_", "."));
            }
        }

        final List<ArtifactCoords> extensionsToAdd = computeCoordsFromQuery(invocation, extensionsQuery);
        if (extensionsToAdd == null) {
            throw new QuarkusCommandException("Failed to create project because of invalid extensions");
        }

        ArtifactCoords bom = null;
        final List<ArtifactCoords> boms = getExtensionBoms(extensionCatalog, extensionsToAdd);
        if (boms.isEmpty()) {
            bom = extensionCatalog.getBom();
        } else {
            final Iterator<ArtifactCoords> i = boms.iterator();
            while (i.hasNext()) {
                final ArtifactCoords next = i.next();
                
                
                if (next.getArtifactId().equals("quarkus-bom")) {
                    bom = next;
                    i.remove();
                    break;
                }
            }
        }

        if (bom == null) {
            throw new QuarkusCommandException("The platform BOM is missing");
        }

        invocation.setValue(BOM_GROUP_ID, bom.getGroupId());
        invocation.setValue(BOM_ARTIFACT_ID, bom.getArtifactId());
        invocation.setValue(BOM_VERSION, bom.getVersion());
        invocation.setValue(QUARKUS_VERSION, extensionCatalog.getQuarkusCoreVersion());

        try {
            Map<String, Object> platformData = new HashMap<>();
            if (extensionCatalog.getMetadata().get("maven") != null) {
                platformData.put("maven", extensionCatalog.getMetadata().get("maven"));
            }
            if (extensionCatalog.getMetadata().get("gradle") != null) {
                platformData.put("gradle", extensionCatalog.getMetadata().get("gradle"));
            }
            final QuarkusCodestartProjectInput input = QuarkusCodestartProjectInput.builder()
                    .addPlatforms(boms)
                    .addExtensions(extensionsToAdd)
                    .buildTool(invocation.getQuarkusProject().getBuildTool())
                    .example(invocation.getValue(EXAMPLE))
                    .noCode(invocation.getValue(NO_CODE, false))
                    .addCodestarts(invocation.getValue(EXTRA_CODESTARTS, Collections.emptySet()))
                    .noBuildToolWrapper(invocation.getValue(NO_BUILDTOOL_WRAPPER, false))
                    .noDockerfiles(invocation.getValue(NO_DOCKERFILES, false))
                    .addData(platformData)
                    .addData(LegacySupport.convertFromLegacy(invocation.getValues()))
                    .putData(APP_CONFIG.key(), invocation.getValue(APP_CONFIG.key(), Collections.emptyMap()))
                    .messageWriter(invocation.log())
                    .build();
            invocation.log().info("-----------");
            if (!extensionsToAdd.isEmpty()) {
                invocation.log().info("selected extensions: \n"
                        + extensionsToAdd.stream().map(e -> "- " + e.getGroupId() + ":" + e.getArtifactId() + "\n")
                                .collect(Collectors.joining()));
            }

            final QuarkusCodestartCatalog catalog = QuarkusCodestartCatalog
                    .fromExtensionsCatalog(invocation.getQuarkusProject().getExtensionsCatalog(),
                            invocation.getQuarkusProject().getCodestartResourceLoaders());
            final CodestartProjectDefinition projectDefinition = catalog.createProject(input);
            projectDefinition.generate(invocation.getQuarkusProject().getProjectDirPath());
            invocation.log()
                    .info("\n-----------\n" + MessageIcons.OK_ICON + " "
                            + projectDefinition.getRequiredCodestart(CodestartType.PROJECT).getName()
                            + " project has been successfully generated in:\n--> "
                            + invocation.getQuarkusProject().getProjectDirPath().toString() + "\n-----------");

        } catch (IOException e) {
            throw new QuarkusCommandException("Failed to create project: " + e.getMessage(), e);
        }

        return QuarkusCommandOutcome.success();
    }