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 copyother 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.common.lib.to;
20  
21  import org.apache.commons.lang3.builder.EqualsBuilder;
22  import org.apache.commons.lang3.builder.HashCodeBuilder;
23  import org.apache.syncope.common.lib.BaseBean;
24  
25  public class RelationshipTO implements BaseBean {
26  
27      private static final long serialVersionUID = 360672942026613929L;
28  
29      public static class Builder {
30  
31          private final RelationshipTO instance = new RelationshipTO();
32  
33          public Builder(final String type) {
34              instance.setType(type);
35          }
36  
37          public Builder otherEnd(final String otherEndType, final String otherEndKey) {
38              instance.setOtherEndType(otherEndType);
39              instance.setOtherEndKey(otherEndKey);
40              return this;
41          }
42  
43          public Builder otherEnd(final String otherEndType, final String otherEndKey, final String otherEndName) {
44              instance.setOtherEndType(otherEndType);
45              instance.setOtherEndKey(otherEndKey);
46              instance.setOtherEndName(otherEndName);
47              return this;
48          }
49  
50          public RelationshipTO build() {
51              return instance;
52          }
53      }
54  
55      private String type;
56  
57      private String otherEndType;
58  
59      private String otherEndKey;
60  
61      private String otherEndName;
62  
63      public String getType() {
64          return type;
65      }
66  
67      public void setType(final String type) {
68          this.type = type;
69      }
70  
71      public String getOtherEndType() {
72          return otherEndType;
73      }
74  
75      public void setOtherEndType(final String otherEndType) {
76          this.otherEndType = otherEndType;
77      }
78  
79      public String getOtherEndKey() {
80          return otherEndKey;
81      }
82  
83      public void setOtherEndKey(final String otherEndKey) {
84          this.otherEndKey = otherEndKey;
85      }
86  
87      public String getOtherEndName() {
88          return otherEndName;
89      }
90  
91      public void setOtherEndName(final String otherEndName) {
92          this.otherEndName = otherEndName;
93      }
94  
95      @Override
96      public int hashCode() {
97          return new HashCodeBuilder().
98                  append(type).
99                  append(otherEndType).
100                 append(otherEndKey).
101                 append(otherEndName).
102                 build();
103     }
104 
105     @Override
106     public boolean equals(final Object obj) {
107         if (this == obj) {
108             return true;
109         }
110         if (obj == null) {
111             return false;
112         }
113         if (getClass() != obj.getClass()) {
114             return false;
115         }
116         final RelationshipTO other = (RelationshipTO) obj;
117         return new EqualsBuilder().
118                 append(type, other.type).
119                 append(otherEndType, other.otherEndType).
120                 append(otherEndKey, other.otherEndKey).
121                 append(otherEndName, other.otherEndName).
122                 build();
123     }
124 }