1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.syncope.core.provisioning.api.rules;
20
21 import java.io.Serializable;
22 import org.apache.commons.lang3.builder.EqualsBuilder;
23 import org.apache.commons.lang3.builder.HashCodeBuilder;
24 import org.apache.syncope.common.lib.types.MatchType;
25 import org.apache.syncope.core.persistence.api.entity.Any;
26 import org.apache.syncope.core.persistence.api.entity.Entity;
27 import org.apache.syncope.core.persistence.api.entity.user.LinkedAccount;
28
29 public final class PullMatch implements Serializable {
30
31 private static final long serialVersionUID = 6515473131174179932L;
32
33 private final MatchType matchTarget;
34
35 private Any<?> any;
36
37 private LinkedAccount linkedAccount;
38
39 public PullMatch(final MatchType matchTarget, final Entity entity) {
40 this.matchTarget = matchTarget;
41
42 if (entity instanceof Any) {
43 any = (Any<?>) entity;
44 } else if (entity instanceof LinkedAccount) {
45 linkedAccount = (LinkedAccount) entity;
46 }
47 }
48
49 public MatchType getMatchTarget() {
50 return matchTarget;
51 }
52
53 public Any<?> getAny() {
54 return any;
55 }
56
57 public LinkedAccount getLinkedAccount() {
58 return linkedAccount;
59 }
60
61 @Override
62 public int hashCode() {
63 return new HashCodeBuilder().
64 append(matchTarget).
65 append(any).
66 append(linkedAccount).
67 build();
68 }
69
70 @Override
71 public boolean equals(final Object obj) {
72 if (this == obj) {
73 return true;
74 }
75 if (obj == null) {
76 return false;
77 }
78 if (getClass() != obj.getClass()) {
79 return false;
80 }
81 final PullMatch other = (PullMatch) obj;
82 return new EqualsBuilder().
83 append(matchTarget, other.matchTarget).
84 append(any, other.any).
85 append(linkedAccount, other.linkedAccount).
86 build();
87 }
88
89 @Override
90 public String toString() {
91 return "PullMatch{"
92 + "matchTarget=" + matchTarget
93 + ", any=" + any
94 + ", linkedAccount=" + linkedAccount
95 + '}';
96 }
97 }