package net.mabako.steamgifts.data;

import net.mabako.steamgifts.core.R;
import net.mabako.steamgifts.adapters.IEndlessAdaptable;

import java.io.Serializable;

/**
 * Comment on a giveaway or discussion.
 */
public class Comment implements Serializable, IEndlessAdaptable {
    private static final long serialVersionUID = -7333245576601696951L;
    public static final int VIEW_LAYOUT = R.layout.comment;

    private final int id;
    private final String author;
    private final String timeAgo;
    private final String timeAgoLong;
    private final String content;
    private final String avatar;
    private final int depth;
    private final boolean op;

    private boolean deleted, highlighted;
    private String permalinkId;

    public Comment(int id, String author, String timeAgo, String timeAgoLong, String content, int depth, String avatar, boolean isOp) {
        this.id = id;
        this.author = author;
        this.timeAgo = timeAgo;
        this.timeAgoLong = timeAgoLong;
        this.content = content;
        this.depth = depth;
        this.avatar = avatar;
        this.op = isOp;
    }

    public int getId() {
        return id;
    }

    public String getAuthor() {
        return author;
    }

    public String getTimeAgo() {
        return timeAgo;
    }

    public String getTimeAgoLong() {
        return timeAgoLong;
    }

    public String getContent() {
        return content;
    }

    public int getDepth() {
        return depth;
    }

    public String getAvatar() {
        return avatar;
    }

    public boolean isDeleted() {
        return deleted;
    }

    public void setDeleted(boolean deleted) {
        this.deleted = deleted;
    }

    public boolean isHighlighted() {
        return highlighted;
    }

    public void setHighlighted(boolean highlighted) {
        this.highlighted = highlighted;
    }

    public boolean isOp() {
        return op;
    }

    public String getPermalinkId() {
        return permalinkId;
    }

    public void setPermalinkId(String permalinkId) {
        this.permalinkId = permalinkId;
    }

    @Override
    public boolean equals(Object o) {
        if (o == null || !(o instanceof Comment))
            return false;

        if (id == 0)
            return false;
        return ((Comment) o).id == id;
    }

    @Override
    public int getLayout() {
        return VIEW_LAYOUT;
    }
}

@@ -63,14 +63,34 @@
 fts.
-core.R
+adapters.IEndlessAdaptable
 ;%0Aim
@@ -120,34 +120,14 @@
 fts.
-adapters.IEndlessAdaptable
+core.R
 ;%0A%0Ai
@@ -2245,17 +2245,174 @@
 id == 0)
+ %7B
 %0A
+            if (permalinkId != null && !%22%22.equals(permalinkId))%0A                return permalinkId.equals(((Comment) o).permalinkId);%0A            else%0A    
         
@@ -2429,16 +2429,26 @@
  false;%0A
+        %7D%0A
         

check for Comment.permalinkId equality if no id is given