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.form;
20
21 import com.fasterxml.jackson.annotation.JsonIgnore;
22 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
23 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
24 import java.util.ArrayList;
25 import java.util.List;
26 import java.util.Optional;
27 import org.apache.commons.lang3.builder.EqualsBuilder;
28 import org.apache.commons.lang3.builder.HashCodeBuilder;
29 import org.apache.syncope.common.lib.BaseBean;
30
31 public class SyncopeForm implements BaseBean {
32
33 private static final long serialVersionUID = 8388697351958834257L;
34
35 private final List<FormProperty> properties = new ArrayList<>();
36
37 @JsonIgnore
38 public Optional<FormProperty> getProperty(final String id) {
39 return properties.stream().filter(property -> id.equals(property.getId())).findFirst();
40 }
41
42 @JacksonXmlElementWrapper(localName = "properties")
43 @JacksonXmlProperty(localName = "property")
44 public List<FormProperty> getProperties() {
45 return properties;
46 }
47
48 @Override
49 public int hashCode() {
50 return new HashCodeBuilder().
51 append(properties).
52 build();
53 }
54
55 @Override
56 public boolean equals(final Object obj) {
57 if (this == obj) {
58 return true;
59 }
60 if (obj == null) {
61 return false;
62 }
63 if (getClass() != obj.getClass()) {
64 return false;
65 }
66 SyncopeForm other = (SyncopeForm) obj;
67 return new EqualsBuilder().
68 append(properties, other.properties).
69 build();
70 }
71 }