package com.smaato.sdk.demoapp;

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

import java.util.Arrays;

public class AdConfig implements Parcelable {

    @NonNull
    public final String name;
    @NonNull
    public final String publisherId;
    @NonNull
    public final String adSpaceId;

    public AdConfig(@NonNull String name, @NonNull String publisherId, @NonNull String adSpaceId) {
        this.name = name;
        this.publisherId = publisherId;
        this.adSpaceId = adSpaceId;
    }

    protected AdConfig(@NonNull Parcel in) {
        name = in.readString();
        publisherId = in.readString();
        adSpaceId = in.readString();
    }

    @Override
    public void writeToParcel(@NonNull Parcel dest, int flags) {
        dest.writeString(name);
        dest.writeString(publisherId);
        dest.writeString(adSpaceId);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof AdConfig)) {
            return false;
        }
        AdConfig adConfig = (AdConfig) o;
        return name.equals(adConfig.name) &&
                publisherId.equals(publisherId) &&
                adSpaceId.equals(adConfig.adSpaceId);
    }

    @Override
    public int hashCode() {
        return Arrays.hashCode(new String[]{name, publisherId, adSpaceId});
    }

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

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

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