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.common.lib.types;
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 SRARoutePredicate implements BaseBean {
26  
27      private static final long serialVersionUID = -635785645207375128L;
28  
29      public static class Builder {
30  
31          private final SRARoutePredicate instance = new SRARoutePredicate();
32  
33          public Builder negate() {
34              instance.setNegate(true);
35              return this;
36          }
37  
38          public Builder cond(final SRARoutePredicateCond cond) {
39              instance.setCond(cond);
40              return this;
41          }
42  
43          public Builder factory(final SRARoutePredicateFactory factory) {
44              instance.setFactory(factory);
45              return this;
46          }
47  
48          public Builder args(final String args) {
49              instance.setArgs(args);
50              return this;
51          }
52  
53          public SRARoutePredicate build() {
54              return instance;
55          }
56      }
57  
58      private boolean negate;
59  
60      private SRARoutePredicateCond cond;
61  
62      private SRARoutePredicateFactory factory;
63  
64      private String args;
65  
66      public boolean isNegate() {
67          return negate;
68      }
69  
70      public void setNegate(final boolean negate) {
71          this.negate = negate;
72      }
73  
74      public SRARoutePredicateCond getCond() {
75          return cond;
76      }
77  
78      public void setCond(final SRARoutePredicateCond cond) {
79          this.cond = cond;
80      }
81  
82      public SRARoutePredicateFactory getFactory() {
83          return factory;
84      }
85  
86      public void setFactory(final SRARoutePredicateFactory factory) {
87          this.factory = factory;
88      }
89  
90      public String getArgs() {
91          return args;
92      }
93  
94      public void setArgs(final String args) {
95          this.args = args;
96      }
97  
98      @Override
99      public int hashCode() {
100         return new HashCodeBuilder().
101                 append(cond).
102                 append(factory).
103                 append(args).
104                 build();
105     }
106 
107     @Override
108     public boolean equals(final Object obj) {
109         if (this == obj) {
110             return true;
111         }
112         if (obj == null) {
113             return false;
114         }
115         if (getClass() != obj.getClass()) {
116             return false;
117         }
118         final SRARoutePredicate other = (SRARoutePredicate) obj;
119         return new EqualsBuilder().
120                 append(cond, other.cond).
121                 append(factory, other.factory).
122                 append(args, other.args).
123                 build();
124     }
125 
126     @Override
127     public String toString() {
128         return "GatewayPredicate{"
129                 + "negate=" + negate
130                 + ", cond=" + cond
131                 + ", factory=" + factory
132                 + ", args=" + args
133                 + '}';
134     }
135 }