package com.foxx.androidcast.ota;

/*********************************************************************
 * OtaChannelPointer.java
 * Created at: Wed 20 May 2026 14:31:55 +0200
 * Updated at: Wed 20 May 2026 15:17:13 +0200 by Anton Afanasyeu <a.afanasieff@gmail.com>
 * Commit: 5d8e82d2e60a21fff3138d2a394ee4e8b4c6dcb8
 * class OtaChannelPointer
 * Contributors:
 *    - Anton Afanasyeu <a.afanasieff@gmail.com> (2 commits, 30 lines)
 *    - Cursor Agent (project assistant)
 * Digest: SHA256	e09bb60ad6b267beca91b6e3bf5f9acc792aedd8cc94fcd85d7137baabbe432b
**********************************************************************/
import org.json.JSONObject;

/** Default-channel entry ({@code v0/ota/channel/stable.json}). */
public final class OtaChannelPointer {
    public final String manifestUrl;

    public OtaChannelPointer(String manifestUrl) {
        this.manifestUrl = manifestUrl != null ? manifestUrl.trim() : "";
    }

    public boolean isValid() {
        return !manifestUrl.isEmpty();
    }

    public static OtaChannelPointer fromJson(JSONObject root) {
        if (root == null) {
            return new OtaChannelPointer("");
        }
        return new OtaChannelPointer(root.optString("manifestUrl", ""));
    }
}
