package com.todoist.pojo;

public class Project extends TodoistObject {
    public static final int MIN_INDENT = 1;
    public static final int MAX_INDENT = 4;

    public static final int MAX_COUNT_FREE = 80;
    public static final int MAX_COUNT_PREMIUM = 300;
    public static final int MAX_COUNT_BUSINESS = 500;
    public static final int MAX_ITEM_COUNT_FREE = 150;
    public static final int MAX_ITEM_COUNT_PREMIUM = 300;
    public static final int MAX_COLLABORATOR_COUNT_FREE = 5;
    public static final int MAX_COLLABORATORS_COUNT_PREMIUM = 25;
    public static final int MAX_COLLABORATORS_COUNT_BUSINESS = 50;

    private String name;
    private int color;
    private int itemOrder;
    private int indent;
    private boolean collapsed;
    private boolean inbox;
    private boolean teamInbox;
    private boolean hasMoreNotes;
    private boolean shared;
    private boolean favorite;
    private boolean archived;

    public Project(long id, String name, int color, int itemOrder, int indent, boolean collapsed, boolean inbox,
                   boolean teamInbox, boolean hasMoreNotes, boolean shared, boolean favorite, boolean archived,
                   boolean deleted) {
        super(id, deleted);
        this.name = sanitizeName(name);
        this.color = color;
        this.itemOrder = itemOrder;
        this.indent = indent;
        this.collapsed = collapsed;
        this.inbox = inbox;
        this.teamInbox = teamInbox;
        this.hasMoreNotes = hasMoreNotes;
        this.shared = shared;
        this.favorite = favorite;
        this.archived = archived;
    }

    public Project(long id, String name, int color, int itemOrder, int indent, boolean collapsed,
                   boolean inbox, boolean teamInbox, boolean hasMoreNotes, boolean shared, boolean favorite) {
        this(id, name, color, itemOrder, indent, collapsed, inbox, teamInbox, hasMoreNotes, shared, favorite, false,
             false);
    }

    public Project(long id, String name, int color, int itemOrder, int indent, boolean favorite) {
        this(id, name, color, itemOrder, indent, false, false, false, false, false, favorite, false, false);
    }

    public Project(long id, String name, int itemOrder) {
        this(id, name, Colors.DEFAULT_COLOR_ID, itemOrder, MIN_INDENT, false, false, false, false, false, false, false, false);
    }

    public String getName() {
        return name;
    }

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

    /**
     * Returns the color id.
     */
    public int getColor() {
        return color;
    }

    /**
     * Returns the color value.
     */
    public int getColorInt() {
        return Colors.getColor(color);
    }

    public void setColor(int color) {
        this.color = color;
    }

    public int getItemOrder() {
        return itemOrder;
    }

    public void setItemOrder(int itemOrder) {
        this.itemOrder = itemOrder;
    }

    /**
     * Returns the indent within the bounds defined by {@link #MIN_INDENT} and {@link #MAX_INDENT}.
     */
    public int getIndent() {
        return Utils.clamp(indent, MIN_INDENT, MAX_INDENT);
    }

    public void setIndent(int indent) {
        this.indent = indent;
    }

    public boolean isCollapsed() {
        return collapsed;
    }

    public void setCollapsed(boolean collapsed) {
        this.collapsed = collapsed;
    }

    public boolean isInbox() {
        return inbox;
    }

    public void setInbox(boolean inbox) {
        this.inbox = inbox;
    }

    public boolean isTeamInbox() {
        return teamInbox;
    }

    public void setTeamInbox(boolean teamInbox) {
        this.teamInbox = teamInbox;
    }

    public boolean hasMoreNotes() {
        return hasMoreNotes;
    }

    public void setHasMoreNotes(boolean hasMoreNotes) {
        this.hasMoreNotes = hasMoreNotes;
    }

    public boolean isShared() {
        return shared;
    }

    public void setShared(boolean shared) {
        this.shared = shared;
    }

    public boolean isFavorite() {
        return favorite;
    }

    public void setFavorite(boolean favorite) {
        this.favorite = favorite;
    }

    public boolean isArchived() {
        return archived;
    }

    public void setArchived(boolean archived) {
        this.archived = archived;
    }

    public static String sanitizeName(String name) {
        if (name != null) {
            name = Sanitizers.PROJECT_NAME_INVALID_PATTERN.matcher(name.trim()).replaceAll(Sanitizers.REPLACEMENT);
        }
        return name;
    }
}

@@ -98,65 +98,24 @@
 nt M
-IN_INDENT = 1;%0A    public static final int MAX_INDENT = 4
+AX_ANCESTORS = 3
 ;%0A%0A 
@@ -637,29 +637,29 @@
 private 
-int itemOrder
+Long parentId
 ;%0A    pr
@@ -668,22 +668,26 @@
 ate int 
-indent
+childOrder
 ;%0A    pr
@@ -948,33 +948,37 @@
 or, 
-int itemOrder, int indent
+Long parentId, int childOrder
 , bo
@@ -1272,59 +1272,65 @@
 his.
-itemOrder = itemOrder;%0A        this.indent = indent
+parentId = parentId;%0A        this.childOrder = childOrder
 ;%0A  
@@ -1630,33 +1630,37 @@
 or, 
-int itemOrder, int indent
+Long parentId, int childOrder
 , bo
@@ -1675,18 +1675,32 @@
 llapsed,
-%0A
  
+boolean inbox,%0A
         
@@ -1709,30 +1709,16 @@
         
-boolean inbox,
  boolean
@@ -1817,33 +1817,36 @@
  color, 
-itemOrder, indent
+parentId, childOrder
 , collap
@@ -1991,33 +1991,37 @@
 or, 
-int itemOrder, int indent
+Long parentId, int childOrder
 , bo
@@ -2072,25 +2072,28 @@
 or, 
-itemOrder, indent
+parentId, childOrder
 , fa
@@ -2198,28 +2198,29 @@
 g name, int 
-item
+child
 Order) %7B%0A   
@@ -2268,29 +2268,24 @@
 ID, 
-itemOrder, MIN_INDENT
+null, childOrder
 , fa
@@ -2322,32 +2322,45 @@
 e, false, false,
+%0A            
  false);%0A    %7D%0A%0A
@@ -2818,24 +2818,24 @@
 lic 
-int getItemOrder
+Long getParentId
 () %7B
@@ -2850,25 +2850,24 @@
  return 
-itemOrder
+parentId
 ;%0A    %7D%0A
@@ -2890,193 +2890,74 @@
  set
-ItemOrder(int itemOrder) %7B%0A        this.itemOrder = itemOrder;%0A    %7D%0A%0A    /**%0A     * Returns the indent within the bounds defined by %7B@link #MIN_INDENT%7D and %7B@link #MAX_INDENT%7D.%0A     */
+ParentId(Long parentId) %7B%0A        this.parentId = parentId;%0A    %7D%0A
 %0A   
@@ -2971,22 +2971,26 @@
  int get
-Indent
+ChildOrder
 () %7B%0A   
@@ -3005,128 +3005,111 @@
 urn 
-Utils.clamp(indent, MIN_INDENT, MAX_INDENT);%0A    %7D%0A%0A    public void setIndent(int indent) %7B%0A        this.indent = indent
+childOrder;%0A    %7D%0A%0A    public void setChildOrder(int childOrder) %7B%0A        this.childOrder = childOrder
 ;%0A  

Replace project item order and indent with child order and parent id