package de.gecheckt.pdf.umbenenner.adapter.in.gui.editor;

import java.util.Objects;

/**
 * Represents the model identifier entered manually by the user when no remote model list
 * is available for the active provider.
 * <p>
 * This record captures both the provider context and the user-supplied model name so that
 * later GUI layers can decide whether the value is still applicable after a provider change
 * or a successful remote list retrieval.
 * <p>
 * A manually entered model name is discarded when a remote model list is subsequently loaded
 * and the previously entered value does not appear in that list.
 *
 * @param providerIdentifier identifier of the provider for which the model was entered;
 *                           never {@code null}
 * @param modelName          model identifier as typed by the user; never {@code null},
 *                           but may be blank when the user has not yet entered anything
 */
public record GuiManualModelEntry(
        String providerIdentifier,
        String modelName) {

    /**
     * Creates a new manual model entry.
     *
     * @param providerIdentifier identifier of the provider; must not be {@code null}
     * @param modelName          model name as entered by the user; must not be {@code null}
     * @throws NullPointerException if any parameter is {@code null}
     */
    public GuiManualModelEntry {
        Objects.requireNonNull(providerIdentifier, "providerIdentifier must not be null");
        Objects.requireNonNull(modelName, "modelName must not be null");
    }

    /**
     * Returns whether the model name is non-blank, i.e. whether the user has entered something.
     *
     * @return {@code true} when the model name contains at least one non-whitespace character
     */
    public boolean hasModelName() {
        return !modelName.isBlank();
    }
}
