1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.syncope.common.lib.request;
20
21 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
22 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
23 import java.util.ArrayList;
24 import java.util.Collection;
25 import java.util.List;
26 import javax.ws.rs.PathParam;
27 import org.apache.syncope.common.lib.BaseBean;
28 import org.apache.syncope.common.lib.types.ResourceDeassociationAction;
29
30
31
32
33 public class ResourceDR implements BaseBean {
34
35 private static final long serialVersionUID = 6295778399633883767L;
36
37 public static class Builder {
38
39 private final ResourceDR instance;
40
41 public Builder() {
42 this.instance = new ResourceDR();
43 }
44
45 public Builder key(final String key) {
46 instance.setKey(key);
47 return this;
48 }
49
50 public Builder action(final ResourceDeassociationAction action) {
51 instance.setAction(action);
52 return this;
53 }
54
55 public Builder resource(final String resource) {
56 if (resource != null) {
57 instance.getResources().add(resource);
58 }
59 return this;
60 }
61
62 public Builder resources(final String... resources) {
63 instance.getResources().addAll(List.of(resources));
64 return this;
65 }
66
67 public Builder resources(final Collection<String> resources) {
68 if (resources != null) {
69 instance.getResources().addAll(resources);
70 }
71 return this;
72 }
73
74 public ResourceDR build() {
75 return instance;
76 }
77 }
78
79 private String key;
80
81 private ResourceDeassociationAction action;
82
83 private final List<String> resources = new ArrayList<>();
84
85 public String getKey() {
86 return key;
87 }
88
89 @PathParam("key")
90 public void setKey(final String key) {
91 this.key = key;
92 }
93
94 public ResourceDeassociationAction getAction() {
95 return action;
96 }
97
98 @PathParam("action")
99 public void setAction(final ResourceDeassociationAction action) {
100 this.action = action;
101 }
102
103 @JacksonXmlElementWrapper(localName = "resources")
104 @JacksonXmlProperty(localName = "resource")
105 public List<String> getResources() {
106 return resources;
107 }
108 }