package ch.pizzalemon.android.model.menu;

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;

import java.io.Serializable;
import java.util.ArrayList;

import ch.pizzalemon.android.R;
import ch.pizzalemon.android.activity.BaseActivity;

/**
 * Created by cimenmus on 08/10/2017.
 */

public class MenuProductModel implements Serializable {

    @Expose @SerializedName("product_id") private String id;
    @Expose @SerializedName("thumb") private String imageURL;
    @Expose @SerializedName("special") private boolean isSpecial;
    @Expose @SerializedName("tax") private boolean isTax;
    @Expose @SerializedName("options") private ArrayList<MenuProductOptionModel> productOptionList;
    private String name;
    private String description;
    private String price;
    private String minimum;
    private int rating;

    private void checkNull(){

        if(id == null)
            id = "";

        if(imageURL == null)
            imageURL = "empty";

        if(name == null)
            name = "";

        if(description == null)
            description = "";

        if(price == null)
            price = "";

        if(minimum == null)
            minimum = "";

        if(productOptionList != null)
            MenuProductOptionModel.checkNull(productOptionList);
    }

    public static void checkNull(ArrayList<MenuProductModel> menuProductModels){
        for(MenuProductModel menuProductModel :  menuProductModels){
            menuProductModel.checkNull();
        }
    }

    public boolean isDescriptionAvailable(){
        return !description.isEmpty() &&
                !description.equals(BaseActivity.currentActivity.getString(R.string.empty_description));
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getImageURL() {
        return imageURL;
    }

    public void setImageURL(String imageURL) {
        this.imageURL = imageURL;
    }

    public boolean isSpecial() {
        return isSpecial;
    }

    public void setSpecial(boolean special) {
        isSpecial = special;
    }

    public boolean isTax() {
        return isTax;
    }

    public void setTax(boolean tax) {
        isTax = tax;
    }

    public ArrayList<MenuProductOptionModel> getProductOptionList() {
        return productOptionList;
    }

    public void setProductOptionList(ArrayList<MenuProductOptionModel> productOptionList) {
        this.productOptionList = productOptionList;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getPrice() {
        return price;
    }

    public void setPrice(String price) {
        this.price = price;
    }

    public String getMinimum() {
        return minimum;
    }

    public void setMinimum(String minimum) {
        this.minimum = minimum;
    }

    public int getRating() {
        return rating;
    }

    public void setRating(int rating) {
        this.rating = rating;
    }
}
