aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/com/pinapelz/query/CommentSearchQueryBuilder.java
blob: 6c1fa908d628c0d627a6dd3460da4de8a017b739 (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
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
package com.pinapelz.query;

import com.pinapelz.vtuber.Language;
import com.pinapelz.vtuber.Organization;
import com.pinapelz.vtuber.Sort;
import com.pinapelz.vtuber.Type;

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

/**
 * Builder for a comment search query
 * Default values set in constructor
 */
public class CommentSearchQueryBuilder {
    private String sort;
    private List<String> target;
    private List<String> conditions;
    private List<String> topic;
    private List<String> vch;
    private List<String> org;
    private List<String> comment;
    private boolean paginated;
    private int offset;
    private int limit;
    private List<String> lang;

    public CommentSearchQueryBuilder(){
        this.sort = "newest";
        this.paginated = true;
        this.offset = 0;
        this.limit = 10;
        this.topic = new ArrayList<String>();
        this.comment = new ArrayList<String>();
        this.org = List.of("Nijisanji");
        this.vch = new ArrayList<String>();
        this.conditions = new ArrayList<String>();
        this.lang = List.of("en");
    }

    public String getSort() {
        return sort;
    }

    public CommentSearchQueryBuilder setSort(String sort) {
        this.sort = sort;
        return this;
    }

    public CommentSearchQueryBuilder setSort(Sort sort) {
        this.sort = sort.toString();
        return this;
    }

    public List<String> getLang() {
        return lang;
    }

    public CommentSearchQueryBuilder setLang(String lang) {
        this.lang = List.of(lang);
        return this;
    }

    public CommentSearchQueryBuilder setLang(Language lang) {
        this.lang = List.of(lang.toString());
        return this;
    }

    public CommentSearchQueryBuilder setLang(Language[] language) {
        List<String> lang = new ArrayList<String>();
        for (Language l : language) {
            lang.add(l.toString());
        }
        this.lang = lang;
        return this;
    }

    public List<String> getTarget() {
        return target;
    }

    public CommentSearchQueryBuilder setTarget(String target) {
        this.target = List.of(target);
        return this;
    }

    public CommentSearchQueryBuilder setTarget(Type target) {
        this.target = List.of(target.toString());
        return this;
    }

    public CommentSearchQueryBuilder setTarget(List<Type> target) {
        List<String> targets = new ArrayList<String>();
        for (Type t : target) {
            targets.add(t.toString());
        }
        this.target = targets;
        return this;
    }



    public List<String> getConditions() {
        return conditions;
    }

    public CommentSearchQueryBuilder setConditions(List<String> conditions) {
        this.conditions = conditions;
        return this;
    }

    public List<String> getTopic() {
        return topic;
    }

    public CommentSearchQueryBuilder setTopic(List<String> topic) {
        this.topic = topic;
        return this;
    }

    public List<String> getVch() {
        return vch;
    }

    public CommentSearchQueryBuilder setVch(List<String> vch) {
        this.vch = vch;
        return this;
    }

    public List<String> getOrg() {
        return org;
    }

    public CommentSearchQueryBuilder setOrg(String org) {
        this.org = List.of(org);
        return this;
    }

    public CommentSearchQueryBuilder setOrg(Organization org) {
        this.org = List.of(org.toString());
        return this;
    }

    public CommentSearchQueryBuilder setOrg(List<Organization> org) {
        List<String> orgs = new ArrayList<String>();
        for (Organization o : org) {
            orgs.add(o.toString());
        }
        this.org = orgs;
        return this;
    }


    public List<String> getComment() {
        return comment;
    }

    public CommentSearchQueryBuilder setComment(List<String> comment) {
        this.comment = comment;
        return this;
    }

    public boolean isPaginated() {
        return paginated;
    }

    public CommentSearchQueryBuilder setPaginated(boolean paginated) {
        this.paginated = paginated;
        return this;
    }

    public int getOffset() {
        return offset;
    }

    public CommentSearchQueryBuilder setOffset(int offset) {
        this.offset = offset;
        return this;
    }

    public int getLimit() {
        return limit;
    }

    public CommentSearchQueryBuilder setLimit(int limit) {
        this.limit = limit;
        return this;
    }
}
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage