1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.syncope.common.rest.api.beans;
20
21 import java.io.Serializable;
22 import java.util.Collection;
23 import java.util.HashSet;
24 import java.util.Optional;
25 import java.util.Set;
26 import java.util.stream.Collectors;
27 import java.util.stream.Stream;
28 import javax.validation.constraints.NotNull;
29 import javax.ws.rs.QueryParam;
30 import org.apache.syncope.common.rest.api.service.JAXRSService;
31
32 public class ReconQuery implements Serializable {
33
34 private static final long serialVersionUID = -3797021989909461591L;
35
36 public static class Builder {
37
38 private final ReconQuery instance;
39
40 public Builder(final String anyTypeKey, final String resourceKey) {
41 instance = new ReconQuery();
42 instance.setAnyTypeKey(anyTypeKey);
43 instance.setResourceKey(resourceKey);
44 }
45
46 public Builder anyKey(final String anyKey) {
47 instance.setAnyKey(anyKey);
48 return this;
49 }
50
51 public Builder fiql(final String fiql) {
52 instance.setFiql(fiql);
53 return this;
54 }
55
56 public Builder moreAttrsToGet(final String... moreAttrsToGet) {
57 if (moreAttrsToGet != null) {
58 Set<String> matg = Optional.ofNullable(instance.getMoreAttrsToGet()).orElseGet(HashSet::new);
59 matg.addAll(Stream.of(moreAttrsToGet).collect(Collectors.toSet()));
60 instance.setMoreAttrsToGet(matg);
61 }
62 return this;
63 }
64
65 public Builder moreAttrsToGet(final Collection<String> moreAttrsToGet) {
66 if (moreAttrsToGet != null) {
67 Set<String> matg = Optional.ofNullable(instance.getMoreAttrsToGet()).orElseGet(HashSet::new);
68 matg.addAll(moreAttrsToGet);
69 instance.setMoreAttrsToGet(matg);
70 }
71 return this;
72 }
73
74 public ReconQuery build() {
75 return instance;
76 }
77 }
78
79 private String anyTypeKey;
80
81 private String anyKey;
82
83 private String resourceKey;
84
85 private String fiql;
86
87 private Set<String> moreAttrsToGet;
88
89 public String getAnyTypeKey() {
90 return anyTypeKey;
91 }
92
93 @NotNull
94 @QueryParam(JAXRSService.PARAM_ANYTYPEKEY)
95 public void setAnyTypeKey(final String anyTypeKey) {
96 this.anyTypeKey = anyTypeKey;
97 }
98
99 public String getAnyKey() {
100 return anyKey;
101 }
102
103 @QueryParam("anyKey")
104 public void setAnyKey(final String anyKey) {
105 this.anyKey = anyKey;
106 }
107
108 public String getResourceKey() {
109 return resourceKey;
110 }
111
112 @NotNull
113 @QueryParam("resourceKey")
114 public void setResourceKey(final String resourceKey) {
115 this.resourceKey = resourceKey;
116 }
117
118 public String getFiql() {
119 return fiql;
120 }
121
122 @QueryParam(JAXRSService.PARAM_FIQL)
123 public void setFiql(final String fiql) {
124 this.fiql = fiql;
125 }
126
127 public Set<String> getMoreAttrsToGet() {
128 return moreAttrsToGet;
129 }
130
131 @QueryParam("moreAttrsToGet")
132 public void setMoreAttrsToGet(final Set<String> moreAttrsToGet) {
133 this.moreAttrsToGet = moreAttrsToGet;
134 }
135 }