package pl.project13.janbanery.resources;

import com.google.gson.annotations.SerializedName;
import pl.project13.janbanery.resources.additions.On;
import pl.project13.janbanery.resources.additions.ReadOnly;
import pl.project13.janbanery.resources.additions.Required;
import pl.project13.janbanery.resources.additions.Settable;

import java.io.Serializable;

/**
 * Describes an column in an Kanban board.
 *
 * @author Konrad Malawski
 */
public class Column extends KanbaneryResource implements Serializable {

  @Required
  @Settable(On.CreateOrUpdate)
  private String name; // on create and update	Name

  @SerializedName("project_id")
  @ReadOnly
  private Integer projectId; //	Project

  @ReadOnly
  private Boolean fixed; //	If column can be moved

  @Settable(On.CreateOrUpdate)
  private Integer capacity; //	Capacity (WIP limit)

  @Settable(On.CreateOrUpdate)
  private Integer position; //	Position on the board, 1-based

  public Column() {
  }

  @Override
  public String getResourceId() {
    return "column";
  }

  public String getName() {
    return name;
  }

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

  public Integer getProjectId() {
    return projectId;
  }

  public void setProjectId(Integer projectId) {
    this.projectId = projectId;
  }

  public Boolean getFixed() {
    return fixed;
  }

  public void setFixed(Boolean fixed) {
    this.fixed = fixed;
  }

  public Integer getCapacity() {
    return capacity;
  }

  public void setCapacity(Integer capacity) {
    this.capacity = capacity;
  }

  public Integer getPosition() {
    return position;
  }

  public void setPosition(Integer position) {
    this.position = position;
  }

  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    if (!super.equals(o)) {
      return false;
    }

    Column column = (Column) o;

    if (capacity != null ? !capacity.equals(column.capacity) : column.capacity != null) {
      return false;
    }
    if (fixed != null ? !fixed.equals(column.fixed) : column.fixed != null) {
      return false;
    }
    if (name != null ? !name.equals(column.name) : column.name != null) {
      return false;
    }
    if (position != null ? !position.equals(column.position) : column.position != null) {
      return false;
    }
    if (projectId != null ? !projectId.equals(column.projectId) : column.projectId != null) {
      return false;
    }

    return true;
  }

  @Override
  public int hashCode() {
    int result = super.hashCode();
    result = 31 * result + (name != null ? name.hashCode() : 0);
    result = 31 * result + (projectId != null ? projectId.hashCode() : 0);
    result = 31 * result + (fixed != null ? fixed.hashCode() : 0);
    result = 31 * result + (capacity != null ? capacity.hashCode() : 0);
    result = 31 * result + (position != null ? position.hashCode() : 0);
    return result;
  }

}

@@ -506,16 +506,48 @@
 able %7B%0A%0A
+  @ReadOnly%0A  private Long id;%0A%0A
   @Requi
@@ -550,16 +550,16 @@
 equired%0A
-
   @Setta
@@ -1054,24 +1054,122 @@
 lumn%22;%0A  %7D%0A%0A
+  public Long getId() %7B%0A    return id;%0A  %7D%0A%0A  public void setId(Long id) %7B%0A    this.id = id;%0A  %7D%0A%0A
   public Str
@@ -2289,32 +2289,124 @@
 rn false;%0A    %7D%0A
+    if (id != null ? !id.equals(column.id) : column.id != null) %7B%0A      return false;%0A    %7D%0A
     if (name != 
@@ -2821,16 +2821,77 @@
 Code();%0A
+    result = 31 * result + (id != null ? id.hashCode() : 0);%0A
     resu
@@ -3262,7 +3262,5 @@
   %7D%0A
-%0A%7D%0A
+%7D

add id to column