package org.tio.sitexxx.service.service.jpush.huawei.webpush;

import com.alibaba.fastjson.annotation.JSONField;
import org.apache.commons.lang.StringUtils;
import org.tio.sitexxx.service.service.jpush.huawei.util.ValidatorUtils;

import java.net.MalformedURLException;
import java.net.URL;

/**
 * <pre>
 *    @author : vagrancy
 *    e-mail : 18050829067@163.com
 *    time   : 2025-02-21 11:08
 *    desc   :
 * </pre>
 */
public class WebHmsOptions {
    @JSONField(name = "link")
    private String link;

    public String getLink() {
        return link;
    }

    public WebHmsOptions(Builder builder) {
        this.link = builder.link;
    }

    public void check() {
        if (!StringUtils.isEmpty(this.link)) {
            try {
                new URL(link);
            } catch (MalformedURLException e) {
                ValidatorUtils.checkArgument(false, "Invalid link");
            }
        }
    }

    /**
     * builder
     */
    public static Builder builder() {
        return new Builder();
    }

    public static class Builder {
        private String link;

        public Builder setLink(String link) {
            this.link = link;
            return this;
        }

        public WebHmsOptions build() {
            return new WebHmsOptions(this);
        }
    }

}
