Repository navigation
Expand file tree
/
Copy pathScheduleArchiveManyParams.java
More file actions
55 lines (46 loc) · 1.69 KB
/
Copy pathScheduleArchiveManyParams.java
File metadata and controls
55 lines (46 loc) · 1.69 KB
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
package com.qoder.cloudagents.forward;
import com.qoder.cloudagents.core.*;
import com.qoder.cloudagents.errors.ConfigurationException;
import java.util.*;
/**
* An explicit, bounded set of Schedule IDs. Requests always carry the only supported scope, {@code
* by_schedule_ids}; the server rejects a missing scope and other extra fields.
*/
public final class ScheduleArchiveManyParams implements JsonSerializable {
private static final String SCOPE = "by_schedule_ids";
private final List<String> ids;
private ScheduleArchiveManyParams(List<String> value) {
if (value == null) throw new ConfigurationException("scheduleIds are required");
LinkedHashSet<String> unique = new LinkedHashSet<>();
for (String id : value) {
if (id == null || id.trim().isEmpty())
throw new ConfigurationException("scheduleIds must not contain empty IDs");
unique.add(id);
}
if (unique.isEmpty() || unique.size() > 50)
throw new ConfigurationException("Supply 1..50 unique schedule IDs");
ids = Collections.unmodifiableList(new ArrayList<>(unique));
}
public List<String> scheduleIds() {
return ids;
}
public JsonValue toJsonValue() {
Map<String, Object> body = new LinkedHashMap<>();
body.put("scope", SCOPE);
body.put("schedule_ids", ids);
return JsonValue.of(body);
}
public static Builder builder() {
return new Builder();
}
public static final class Builder {
private List<String> ids;
public Builder scheduleIds(List<String> value) {
ids = value == null ? null : new ArrayList<>(value);
return this;
}
public ScheduleArchiveManyParams build() {
return new ScheduleArchiveManyParams(ids);
}
}
}