package p.studio.workspaces.assets.details;

import p.packer.messages.AssetReference;
import p.studio.workspaces.assets.messages.AssetWorkspaceAssetDetails;
import p.studio.workspaces.assets.messages.AssetWorkspaceDetailsStatus;
import p.studio.workspaces.assets.messages.AssetWorkspaceDetailsViewState;

import java.util.Objects;

public final class AssetDetailsViewStateFactory {
    private AssetDetailsViewStateFactory() {
    }

    public static AssetWorkspaceDetailsViewState empty() {
        return new AssetWorkspaceDetailsViewState(
                AssetWorkspaceDetailsStatus.EMPTY,
                null,
                null,
                null);
    }

    public static AssetWorkspaceDetailsViewState loading(AssetReference assetReference) {
        return new AssetWorkspaceDetailsViewState(
                AssetWorkspaceDetailsStatus.LOADING,
                Objects.requireNonNull(assetReference, "assetReference"),
                null,
                null);
    }

    public static AssetWorkspaceDetailsViewState ready(
            AssetReference assetReference,
            AssetWorkspaceAssetDetails details) {
        return new AssetWorkspaceDetailsViewState(
                AssetWorkspaceDetailsStatus.READY,
                Objects.requireNonNull(assetReference, "assetReference"),
                Objects.requireNonNull(details, "details"),
                null);
    }

    public static AssetWorkspaceDetailsViewState error(
            AssetReference assetReference,
            String message) {
        return new AssetWorkspaceDetailsViewState(
                AssetWorkspaceDetailsStatus.ERROR,
                assetReference,
                null,
                Objects.requireNonNullElse(message, "Unknown asset details error"));
    }
}
