package kr.co.icontrols.iotplatform.DataClass;

import android.os.Parcel;
import android.os.Parcelable;

import java.io.Serializable;

public class DeviceGroupInfo implements Serializable, Parcelable{
    public String dgroupId;
    public String friendlyName;
    public String icon;
    public int index;
    public int deviceCount;
    public int isSelected;

    public DeviceGroupInfo(String dgroupId,
                     String friendlyName,
                     String icon,
                     int index) {
        this.dgroupId = dgroupId;
        this.friendlyName = friendlyName;
        this.icon = icon;
        this.index = index;
        this.deviceCount = 0;
        this.isSelected = 0;
    }

    public DeviceGroupInfo(DeviceGroupInfo item) {
        this.dgroupId = item.dgroupId;
        this.friendlyName = item.friendlyName;
        this.icon = item.icon;
        this.index = item.index;
        this.deviceCount = item.deviceCount;
        this.isSelected = item.isSelected;
    }

    public DeviceGroupInfo(Parcel item) {
        this.dgroupId = item.readString();
        this.friendlyName = item.readString();
        this.icon = item.readString();
        this.index = item.readInt();
        this.deviceCount = item.readInt();
        this.isSelected = item.readInt();
    }

    public boolean isSelected() {
        return isSelected != 0;
    }

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

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.dgroupId);
        dest.writeString(this.friendlyName);
        dest.writeString(this.icon);
        dest.writeInt(this.index);
        dest.writeInt(this.deviceCount);
        dest.writeInt(this.isSelected);
    }

    @SuppressWarnings("rawtypes")
    public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {

        @Override
        public DeviceGroupInfo createFromParcel(Parcel in) {
            return new DeviceGroupInfo(in);
        }

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