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 org.apache.commons.lang3.builder.EqualsBuilder;
27 import org.apache.commons.lang3.builder.HashCodeBuilder;
28
29 public class PasswordPatch extends StringReplacePatchItem {
30
31 private static final long serialVersionUID = 961023537479513071L;
32
33 public static class Builder extends AbstractReplacePatchItem.Builder<String, PasswordPatch, Builder> {
34
35 @Override
36 protected PasswordPatch newInstance() {
37 return new PasswordPatch();
38 }
39
40 public Builder onSyncope(final boolean onSyncope) {
41 getInstance().setOnSyncope(onSyncope);
42 return this;
43 }
44
45 public Builder resource(final String resource) {
46 if (resource != null) {
47 getInstance().getResources().add(resource);
48 }
49 return this;
50 }
51
52 public Builder resources(final String... resources) {
53 getInstance().getResources().addAll(List.of(resources));
54 return this;
55 }
56
57 public Builder resources(final Collection<String> resources) {
58 if (resources != null) {
59 getInstance().getResources().addAll(resources);
60 }
61 return this;
62 }
63 }
64
65
66
67
68 private boolean onSyncope = true;
69
70
71
72
73 private final List<String> resources = new ArrayList<>();
74
75 public boolean isOnSyncope() {
76 return onSyncope;
77 }
78
79 public void setOnSyncope(final boolean onSyncope) {
80 this.onSyncope = onSyncope;
81 }
82
83 @JacksonXmlElementWrapper(localName = "resources")
84 @JacksonXmlProperty(localName = "resource")
85 public List<String> getResources() {
86 return resources;
87 }
88
89 @Override
90 public int hashCode() {
91 return new HashCodeBuilder().
92 appendSuper(super.hashCode()).
93 append(onSyncope).
94 append(resources).
95 build();
96 }
97
98 @Override
99 public boolean equals(final Object obj) {
100 if (this == obj) {
101 return true;
102 }
103 if (obj == null) {
104 return false;
105 }
106 if (getClass() != obj.getClass()) {
107 return false;
108 }
109 final PasswordPatch other = (PasswordPatch) obj;
110 return new EqualsBuilder().
111 appendSuper(super.equals(obj)).
112 append(onSyncope, other.onSyncope).
113 append(resources, other.resources).
114 build();
115 }
116 }