View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
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  }