<commit_before>package com.kii.thingif;

import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.NonNull;
import android.text.TextUtils;

/** Represents Application on Kii Cloud */
public class KiiApp implements Parcelable {
    private String appID;
    private String appKey;
    private String hostName;
    private String baseUrl;
    private String siteName;
    private Site site;


    /** Instantiate Kii App with App Location.
     * If you haven't created Kii Cloud App yet,
     * Please visit https://developer.kii.com and create your app.
     * @param appID ID of the app.
     * @param appKey Key of the app.
     * @param site Site of the app.
     * @throws  IllegalArgumentException when appID, appKey and site is null or empty string.
     */
    public KiiApp(String appID, String appKey, Site site) {
        if (TextUtils.isEmpty(appID)) {
            throw new IllegalArgumentException("appID is null or empty.");
        }
        if (TextUtils.isEmpty(appKey)) {
            throw new IllegalArgumentException("appKey is null or empty.");
        }
        if (site == null) {
            throw new IllegalArgumentException("site is null.");
        }
        this.appID = appID;
        this.appKey = appKey;
        this.site = site;
        this.hostName = site.getHostName();
        this.baseUrl = site.getBaseUrl();
        this.siteName = site.name();
    }

    /** Instantiate Kii App with Host Name.
     * Who host Kii Cloud in private/ dedicated location
     * Will use this constructor to instantiate KiiApp.
     * (Private/ Dedicated location is only available in Enterprise subscription.)
     * If you're using public Kii Cloud, please use {@link KiiApp(String, String, Site)}
     * With this constructor, {@link #getSiteName()} returns fixed string "CUSTOM".
     * @param appID ID of the app.
     * @param appKey Key of the app.
     * @param hostName Host Name of the app.
     * @throws  IllegalArgumentException when appID, appKey and hostName is null or empty string.
     */
    KiiApp(String appID, String appKey, String hostName) {
        if (TextUtils.isEmpty(appID)) {
            throw new IllegalArgumentException("appID is null or empty.");
        }
        if (TextUtils.isEmpty(appKey)) {
            throw new IllegalArgumentException("appKey is null or empty.");
        }
        if (TextUtils.isEmpty(hostName)) {
            throw new IllegalArgumentException("hostName is null or empty.");
        }
        this.appID = appID;
        this.appKey = appKey;
        this.site = null;
        this.hostName = hostName;
        this.baseUrl = "https://" + hostName;
        this.siteName = "CUSTOM";
    }

    protected KiiApp(Parcel in) {
        appID = in.readString();
        appKey = in.readString();
        site = (Site)in.readSerializable();
        hostName = in.readString();
        baseUrl = in.readString();
        siteName = in.readString();
    }

    public static final Creator<KiiApp> CREATOR = new Creator<KiiApp>() {
        @Override
        public KiiApp createFromParcel(Parcel in) {
            return new KiiApp(in);
        }

        @Override
        public KiiApp[] newArray(int size) {
            return new KiiApp[size];
        }
    };

    public String getAppID() {
        return this.appID;
    }

    public String getAppKey() {
        return  this.appKey;
    }

    public Site getSite() {
        return this.site;
    }

    public String getHostName() {
        return this.hostName;
    }

    public String getBaseUrl() {
        return this.baseUrl;
    }

    public String getSiteName() {
        return this.siteName;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(appID);
        dest.writeString(appKey);
        dest.writeSerializable(site);
        dest.writeString(hostName);
        dest.writeString(baseUrl);
        dest.writeString(siteName);
    }


    /** KiiApp Builder.
     * Provides fine grained control on creating KiiApp instance.<br>
     * For Private/ Dedicated Kii Cloud instance users.<br><br>
     *
     * Public Kii Cloud user who uses apps created on https://developer.kii.com does not need to
     * interact with this Builder. Just use {@link KiiApp(String, String, Site)} is fine.
     */
    public static class Builder {
        final private String hostName;
        final private String appID;
        final private String appKey;
        private String siteName;
        private int port;
        private String schema;<commit_msg>remove KiiApp.site attribute and use siteName to get the Site enum<commit_after>package com.kii.thingif;

import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.NonNull;
import android.text.TextUtils;

/** Represents Application on Kii Cloud */
public class KiiApp implements Parcelable {
    private String appID;
    private String appKey;
    private String hostName;
    private String baseUrl;
    private String siteName;


    /** Instantiate Kii App with App Location.
     * If you haven't created Kii Cloud App yet,
     * Please visit https://developer.kii.com and create your app.
     * @param appID ID of the app.
     * @param appKey Key of the app.
     * @param site Site of the app.
     * @throws  IllegalArgumentException when appID, appKey and site is null or empty string.
     */
    public KiiApp(String appID, String appKey, Site site) {
        if (TextUtils.isEmpty(appID)) {
            throw new IllegalArgumentException("appID is null or empty.");
        }
        if (TextUtils.isEmpty(appKey)) {
            throw new IllegalArgumentException("appKey is null or empty.");
        }
        if (site == null) {
            throw new IllegalArgumentException("site is null.");
        }
        this.appID = appID;
        this.appKey = appKey;
        this.hostName = site.getHostName();
        this.baseUrl = site.getBaseUrl();
        this.siteName = site.name();
    }

    /** Instantiate Kii App with Host Name.
     * Who host Kii Cloud in private/ dedicated location
     * Will use this constructor to instantiate KiiApp.
     * (Private/ Dedicated location is only available in Enterprise subscription.)
     * If you're using public Kii Cloud, please use {@link KiiApp(String, String, Site)}
     * With this constructor, {@link #getSiteName()} returns fixed string "CUSTOM".
     * @param appID ID of the app.
     * @param appKey Key of the app.
     * @param hostName Host Name of the app.
     * @throws  IllegalArgumentException when appID, appKey and hostName is null or empty string.
     */
    KiiApp(String appID, String appKey, String hostName) {
        if (TextUtils.isEmpty(appID)) {
            throw new IllegalArgumentException("appID is null or empty.");
        }
        if (TextUtils.isEmpty(appKey)) {
            throw new IllegalArgumentException("appKey is null or empty.");
        }
        if (TextUtils.isEmpty(hostName)) {
            throw new IllegalArgumentException("hostName is null or empty.");
        }
        this.appID = appID;
        this.appKey = appKey;
        this.hostName = hostName;
        this.baseUrl = "https://" + hostName;
        this.siteName = "CUSTOM";
    }

    protected KiiApp(Parcel in) {
        appID = in.readString();
        appKey = in.readString();
        hostName = in.readString();
        baseUrl = in.readString();
        siteName = in.readString();
    }

    public static final Creator<KiiApp> CREATOR = new Creator<KiiApp>() {
        @Override
        public KiiApp createFromParcel(Parcel in) {
            return new KiiApp(in);
        }

        @Override
        public KiiApp[] newArray(int size) {
            return new KiiApp[size];
        }
    };

    public String getAppID() {
        return this.appID;
    }

    public String getAppKey() {
        return  this.appKey;
    }

    public Site getSite() {
        if ("CUSTOM".equals(this.siteName)) {
            return null;
        }
        return Site.valueOf(this.siteName);
    }

    public String getHostName() {
        return this.hostName;
    }

    public String getBaseUrl() {
        return this.baseUrl;
    }

    public String getSiteName() {
        return this.siteName;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(appID);
        dest.writeString(appKey);
        dest.writeString(hostName);
        dest.writeString(baseUrl);
        dest.writeString(siteName);
    }


    /** KiiApp Builder.
     * Provides fine grained control on creating KiiApp instance.<br>
     * For Private/ Dedicated Kii Cloud instance users.<br><br>
     *
     * Public Kii Cloud user who uses apps created on https://developer.kii.com does not need to
     * interact with this Builder. Just use {@link KiiApp(String, String, Site)} is fine.
     */
    public static class Builder {
        final private String hostName;
        final private String appID;
        final private String appKey;
        private String siteName;
        private int port;
        private String schema;
{'fraction_non_alphanumeric': 0.09173029357995484, 'fraction_numerical': 0.00021507688998817078, 'mean_word_length': 2.2838983050847457, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1210026', 'n_tokens_mistral': 2610, 'n_tokens_neox': 2558, 'n_words': 837}