Welcome to mirror list, hosted at ThFree Co, Russian Federation.

FilterInformation.java « internal « model « deck « nextcloud « niedermann « it « java « main « src « app - github.com/stefan-niedermann/nextcloud-deck.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8c7da2b242b06e9f5d40c5292d4635d17c281eb4 (plain)
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
package it.niedermann.nextcloud.deck.model.internal;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import it.niedermann.nextcloud.deck.model.Label;
import it.niedermann.nextcloud.deck.model.User;
import it.niedermann.nextcloud.deck.model.enums.EDoneType;
import it.niedermann.nextcloud.deck.model.enums.EDueType;
import it.niedermann.nextcloud.deck.model.ocs.projects.OcsProject;

public class FilterInformation implements Serializable {

    public enum EArchiveStatus {
        ALL, ARCHIVED, NON_ARCHIVED
    }

    @NonNull
    private EDueType dueType = EDueType.NO_FILTER;
    @NonNull
    private EDoneType doneType = EDoneType.NO_FILTER;
    private boolean noAssignedLabel = false;
    private boolean noAssignedUser = false;
    private boolean noAssignedProject = false;
    @NonNull
    private List<User> users = new ArrayList<>();
    @NonNull
    private List<Label> labels = new ArrayList<>();
    @NonNull
    private List<OcsProject> projects = new ArrayList<>();
    @NonNull
    private EArchiveStatus archiveStatus = EArchiveStatus.NON_ARCHIVED;
    @NonNull
    private String filterText = "";

    public FilterInformation() {
        // Default constructor
    }

    public FilterInformation(@Nullable FilterInformation filterInformation) {
        if (filterInformation != null) {
            this.dueType = filterInformation.getDueType();
            this.doneType = filterInformation.getDoneType();
            this.archiveStatus = filterInformation.getArchiveStatus();
            this.users.addAll(filterInformation.getUsers());
            this.labels.addAll(filterInformation.getLabels());
            this.noAssignedUser = filterInformation.isNoAssignedUser();
            this.noAssignedLabel = filterInformation.isNoAssignedLabel();
            this.archiveStatus = filterInformation.getArchiveStatus();
            this.noAssignedProject = filterInformation.isNoAssignedProject();
            this.projects = filterInformation.getProjects();
            this.filterText = filterInformation.getFilterText();
        }
    }

    public void setFilterText(@NonNull String filterText) {
        this.filterText = filterText;
    }

    @NonNull
    public String getFilterText() {
        return this.filterText;
    }

    @NonNull
    public EDueType getDueType() {
        return dueType;
    }

    public void setDueType(@NonNull EDueType dueType) {
        this.dueType = dueType;
    }

    @NonNull
    public EDoneType getDoneType() {
        return doneType;
    }

    public void setDoneType(@NonNull EDoneType doneType) {
        this.doneType = doneType;
    }

    @NonNull
    public List<User> getUsers() {
        return users;
    }

    @NonNull
    public List<Label> getLabels() {
        return labels;
    }

    public void addLabel(@NonNull Label label) {
        this.labels.add(label);
    }

    public void addUser(@NonNull User user) {
        this.users.add(user);
    }

    public void removeLabel(@NonNull Label label) {
        labels.remove(label);
    }

    public void removeUser(@NonNull User user) {
        users.remove(user);
    }

    public boolean isNoAssignedUser() {
        return noAssignedUser;
    }

    public void setNoAssignedUser(boolean noAssignedUser) {
        this.noAssignedUser = noAssignedUser;
    }

    public boolean isNoAssignedLabel() {
        return noAssignedLabel;
    }

    public void setNoAssignedLabel(boolean noAssignedLabel) {
        this.noAssignedLabel = noAssignedLabel;
    }

    public void setArchiveStatus(@NonNull EArchiveStatus archiveStatus) {
        this.archiveStatus = archiveStatus;
    }

    public void setUsers(@NonNull List<User> users) {
        this.users = users;
    }

    public boolean isNoAssignedProject() {
        return noAssignedProject;
    }

    public void setNoAssignedProject(boolean noAssignedProject) {
        this.noAssignedProject = noAssignedProject;
    }

    public void setLabels(@NonNull List<Label> labels) {
        this.labels = labels;
    }

    @NonNull
    public List<OcsProject> getProjects() {
        return projects;
    }

    public void setProjects(@NonNull List<OcsProject> projects) {
        this.projects = projects;
    }

    @NonNull
    public EArchiveStatus getArchiveStatus() {
        return archiveStatus;
    }

    @NonNull
    @Override
    public String toString() {
        return "FilterInformation{" +
                "dueType=" + dueType +
                ", doneType=" + doneType +
                ", noAssignedLabel=" + noAssignedLabel +
                ", noAssignedUser=" + noAssignedUser +
                ", users=" + users +
                ", labels=" + labels +
                ", archiveStatus=" + archiveStatus +
                ", filterText=" + filterText +
                '}';
    }

    /**
     * @return whether or not the given {@param filterInformation} has any actual filters except {@link #filterText}
     */
    public static boolean hasActiveFilter(@Nullable FilterInformation filterInformation) {
        if (filterInformation == null) {
            return false;
        }
        return !(filterInformation.getDueType() == EDueType.NO_FILTER
                && filterInformation.getDoneType() == EDoneType.NO_FILTER
                && filterInformation.getUsers().isEmpty()
                && filterInformation.getProjects().isEmpty()
                && filterInformation.getLabels().isEmpty()
                && !filterInformation.noAssignedUser
                && !filterInformation.noAssignedProject
                && !filterInformation.noAssignedLabel);
    }
}