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: 1b5f0879d438ffc6def10a3cd103affc5902045d (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
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.EDueType;

public class FilterInformation implements Serializable {

    public enum EArchiveStatus{
        ALL, ARCHIVED, NON_ARCHIVED
    }

    @NonNull
    private EDueType dueType = EDueType.NO_FILTER;
    private boolean noAssignedLabel = false;
    private boolean noAssignedUser = false;
    @NonNull
    private List<User> users = new ArrayList<>();
    @NonNull
    private List<Label> labels = new ArrayList<>();
    @NonNull
    private EArchiveStatus archiveStatus = EArchiveStatus.NON_ARCHIVED;

    public FilterInformation() {
        // Default constructor
    }

    public FilterInformation(@Nullable FilterInformation filterInformation) {
        if (filterInformation != null) {
            this.dueType = filterInformation.getDueType();
            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();
        }
    }

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

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

    @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;
    }

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

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

    /**
     * @return whether or not the given {@param filterInformation} has any actual filters set
     */
    public static boolean hasActiveFilter(@Nullable FilterInformation filterInformation) {
        if (filterInformation == null) {
            return false;
        }
        return filterInformation.getDueType() != EDueType.NO_FILTER
                || filterInformation.getUsers().size() > 0
                || filterInformation.getLabels().size() > 0
                || filterInformation.noAssignedUser
                || filterInformation.noAssignedLabel;
    }
}