package org.tndata.android.compass.model;

import android.os.Parcel;

import com.google.gson.annotations.SerializedName;


/**
 * Model class for actions.
 *
 * @author Edited by Ismael Alonso
 * @version 1.0.0
 */
public class TDCAction extends TDCContent{
    public static final String TYPE = "action";


    @SerializedName("sequence_order")
    private int mSequenceOrder;
    @SerializedName("more_info")
    private String mMoreInfo;
    @SerializedName("html_more_info")
    private String mHtmlMoreInfo;
    @SerializedName("external_resource")
    private String mExternalResource;
    @SerializedName("external_resource_name")
    private String mExternalResourceName;
    @SerializedName("default_trigger")
    private Trigger mTrigger;

    @SerializedName("behavior")
    private long mBehaviorId;
    @SerializedName("behavior_title")
    private String mBehaviorTitle;


    /*---------*
     * GETTERS *
     *---------*/

    public int getSequenceOrder(){
        return mSequenceOrder;
    }

    public String getMoreInfo(){
        return mMoreInfo;
    }

    public String getHTMLMoreInfo(){
        return mHtmlMoreInfo;
    }

    public String getExternalResource(){
        return mExternalResource;
    }

    public String getExternalResourceName(){
        return mExternalResourceName;
    }

    public Trigger getTrigger(){
        return mTrigger;
    }

    public long getBehaviorId(){
        return mBehaviorId;
    }

    public String getBehaviorTitle(){
        return mBehaviorTitle == null ? "" : mBehaviorTitle;
    }

    @Override
    protected String getType(){
        return TYPE;
    }


    /*---------*
     * UTILITY *
     *---------*/

    @Override
    public String toString(){
        return "ActionContent #" + getId() + ": " + getTitle();
    }

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

    @Override
    public void writeToParcel(Parcel dest, int flags){
        super.writeToParcel(dest, flags);
        dest.writeInt(mSequenceOrder);
        dest.writeString(mMoreInfo);
        dest.writeString(mHtmlMoreInfo);
        dest.writeString(mExternalResource);
        dest.writeString(mExternalResourceName);
        dest.writeByte((byte)(mTrigger != null ? 1 : 0));
        if (mTrigger != null){
            dest.writeParcelable(mTrigger, flags);
        }
        dest.writeLong(mBehaviorId);
        dest.writeString(mBehaviorTitle);
    }

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

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

    /**
     * Constructor to create from parcel.
     *
     * @param src the parcel where the object is stored.
     */
    private TDCAction(Parcel src){
        super(src);
        mSequenceOrder = src.readInt();
        mMoreInfo = src.readString();
        mHtmlMoreInfo = src.readString();
        mExternalResource = src.readString();
        mExternalResourceName = src.readString();
        if (src.readByte() == 1){
            mTrigger = src.readParcelable(Trigger.class.getClassLoader());
        }
        mBehaviorId = src.readLong();
        mBehaviorTitle = src.readString();
    }
}

@@ -676,77 +676,8 @@
 ame;
-%0A    @SerializedName(%22default_trigger%22)%0A    private Trigger mTrigger;
 %0A%0A  
@@ -872,298 +872,814 @@
     
-public int getSequenceOrder()%7B%0A        return mSequenceOrder;%0A    %7D%0A%0A    public String getMoreInfo()%7B%0A        return mMoreInfo;%0A    %7D%0A%0A    public String getHTMLMoreInfo()%7B%0A        return mHtmlMoreInfo;%0A    %7D%0A%0A    public String getExternalResource()%7B%0A        return mExternalResource;%0A    %7D%0A
+/**%0A     * Sequence order getter.%0A     *%0A     * @return the action's sequence order position.%0A     */%0A    public int getSequenceOrder()%7B%0A        return mSequenceOrder;%0A    %7D%0A%0A    /**%0A     * More info getter.%0A     *%0A     * @return the action's more info.%0A     */%0A    public String getMoreInfo()%7B%0A        return mMoreInfo;%0A    %7D%0A%0A    /**%0A     * HTML more info getter.%0A     *%0A     * @return the action's more info in HTML format.%0A     */%0A    public String getHTMLMoreInfo()%7B%0A        return mHtmlMoreInfo;%0A    %7D%0A%0A    /**%0A     * External resource getter.%0A     *%0A     * @return the action's external resource.%0A     */%0A    public String getExternalResource()%7B%0A        return mExternalResource;%0A    %7D%0A%0A    /**%0A     * External resource name getter.%0A     *%0A     * @return the action's external resource name.%0A     */
 %0A   
@@ -1773,68 +1773,108 @@
     
-public Trigger getTrigger()%7B
+/**%0A     * Behavior id getter.
 %0A    
+ *%0A
     
+ * @
 return 
-mTrigger;
+the id of the action's parent behavior.
 %0A    
-%7D%0A
+ */
 %0A   
@@ -1930,32 +1930,143 @@
 aviorId;%0A    %7D%0A%0A
+    /**%0A     * Behavior title getter.%0A     *%0A     * @return the title of the action's parent behavior.%0A     */%0A
     public Strin
@@ -2105,38 +2105,8 @@
 turn
- mBehaviorTitle == null ? %22%22 :
  mBe
@@ -2372,82 +2372,8 @@
  %7D%0A%0A
-    @Override%0A    public int describeContents()%7B%0A        return 0;%0A    %7D%0A%0A
     
@@ -2694,158 +2694,8 @@
 e);%0A
-        dest.writeByte((byte)(mTrigger != null ? 1 : 0));%0A        if (mTrigger != null)%7B%0A            dest.writeParcelable(mTrigger, flags);%0A        %7D%0A
     
@@ -3496,127 +3496,8 @@
 ();%0A
-        if (src.readByte() == 1)%7B%0A            mTrigger = src.readParcelable(Trigger.class.getClassLoader());%0A        %7D%0A
     

Document and cleanup TDCAction