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.to;
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.Optional;
25 import java.util.Set;
26 import java.util.TreeSet;
27 import org.apache.commons.lang3.builder.EqualsBuilder;
28 import org.apache.commons.lang3.builder.HashCodeBuilder;
29 import org.apache.syncope.common.lib.Attr;
30 import org.apache.syncope.common.lib.BaseBean;
31
32 public class ConnObject implements BaseBean {
33
34 private static final long serialVersionUID = 5139554911265442497L;
35
36 private String fiql;
37
38 private final Set<Attr> attrs = new TreeSet<>();
39
40 public String getFiql() {
41 return fiql;
42 }
43
44 public void setFiql(final String fiql) {
45 this.fiql = fiql;
46 }
47
48 @JacksonXmlElementWrapper(localName = "attrs")
49 @JacksonXmlProperty(localName = "attr")
50 public Set<Attr> getAttrs() {
51 return attrs;
52 }
53
54 @JsonIgnore
55 public Optional<Attr> getAttr(final String schema) {
56 return attrs.stream().filter(attr -> attr.getSchema().equals(schema)).findFirst();
57 }
58
59 @Override
60 public int hashCode() {
61 return new HashCodeBuilder().
62 append(fiql).
63 append(attrs).
64 build();
65 }
66
67 @Override
68 public boolean equals(final Object obj) {
69 if (this == obj) {
70 return true;
71 }
72 if (obj == null) {
73 return false;
74 }
75 if (getClass() != obj.getClass()) {
76 return false;
77 }
78 final ConnObject other = (ConnObject) obj;
79 return new EqualsBuilder().
80 append(fiql, other.fiql).
81 append(attrs, other.attrs).
82 build();
83 }
84 }