Skip to main content
summaryrefslogtreecommitdiffstats
blob: e8911df78941458cf0334111376fa7089447ec3f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/*******************************************************************************
 * Copyright (c) 2004 - 2005 University Of British Columbia and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     University Of British Columbia - initial API and implementation
 *******************************************************************************/
/*
 * Created on Jan 24, 2005
 */
package org.eclipse.mylyn.tasklist.tests;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Shawn Minto
 * 
 * TODO: remove?
 */
public class TaskTest {
    private int id = -1;

    private String name = "";

    private List<String> categories = new ArrayList<String>();

    private List<TaskTest> taskList = new ArrayList<TaskTest>();

    @Override
    public String toString() {
        return "Task";
    }

    public boolean isEqual(TaskTest otherTask) {

        boolean result = true;
        result = result && (this.id == otherTask.id);
        int compare = (this.name.compareTo(otherTask.name));
        if (compare != 0)
            result = false;

        if (this.categories.size() == otherTask.categories.size()) {
            for (int i = 0; i < this.categories.size(); i++) {
                compare = this.categories.get(i).compareTo(
                        otherTask.categories.get(i));
                if (compare != 0) {
                    result = false;
                    break;
                }
            }
        } else {
            result = false;
        }
        if (this.taskList.size() == otherTask.taskList.size()) {
            for (int i = 0; i < this.taskList.size(); i++) {
                result = result
                        && (this.taskList.get(i).isEqual(otherTask.taskList
                                .get(i)));
            }
        } else {
            result = false;
        }
        return result;
    }

    public static void printTask(TaskTest t, String tab) {
        System.out.println(tab + "TaskID: " + t.id);
        System.out.println(tab + "Name: " + t.name);
        System.out.println(tab + "Categories: ");
        for (int i = 0; i < t.categories.size(); i++) {
            System.out.println(tab + "\t " + t.categories.get(i));
        }
        for (int i = 0; i < t.taskList.size(); i++) {
            printTask(t.taskList.get(i), tab + "\t");
        }
    }

    public String getName() {
        return name;
    }

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

    //    public List<String> getCategories() {
    //        return categories;
    //    }
    //    public void setCategories(List<String> categories) {
    //        this.categories = categories;
    //    }
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public void addCategory(String category) {
        this.categories.add(category);
    }

    /**
     * @return Returns the categories.
     */
    public List<String> getCategories() {
        return categories;
    }

    /**
     * @param categories The categories to set.
     */
    public void setCategories(List<String> categories) {
        this.categories = categories;
    }

    /**
     * @return Returns the taskList.
     */
    public List<TaskTest> getTaskList() {
        return taskList;
    }

    /**
     * @param taskList The taskList to set.
     */
    public void setTaskList(List<TaskTest> taskList) {
        this.taskList = taskList;
    }

    public void addSubTask(TaskTest sub) {
        this.taskList.add(sub);
    }
}

Back to the top