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.request;
20  
21  import java.util.Collection;
22  import javax.ws.rs.PathParam;
23  import org.apache.commons.lang3.builder.EqualsBuilder;
24  import org.apache.commons.lang3.builder.HashCodeBuilder;
25  import org.apache.syncope.common.lib.types.StatusRType;
26  
27  public class StatusR extends PasswordPatch {
28  
29      private static final long serialVersionUID = 99309988426922612L;
30  
31      public static class Builder extends PasswordPatch.Builder {
32  
33          public Builder(final String key, final StatusRType type) {
34              getInstance().setKey(key);
35              getInstance().setType(type);
36          }
37  
38          @Override
39          protected StatusR newInstance() {
40              return new StatusR();
41          }
42  
43          @Override
44          protected StatusR getInstance() {
45              return (StatusR) super.getInstance();
46          }
47  
48          @Override
49          public StatusR build() {
50              return (StatusR) super.build();
51          }
52  
53          @Override
54          public Builder onSyncope(final boolean onSyncope) {
55              return (Builder) super.onSyncope(onSyncope);
56          }
57  
58          @Override
59          public Builder resource(final String resource) {
60              return (Builder) super.resource(resource);
61          }
62  
63          @Override
64          public Builder resources(final Collection<String> resources) {
65              return (Builder) super.resources(resources);
66          }
67  
68          @Override
69          public Builder resources(final String... resources) {
70              return (Builder) super.resources(resources);
71          }
72  
73          public Builder token(final String token) {
74              getInstance().setToken(token);
75              return this;
76          }
77      }
78  
79      /**
80       * Key of user to for which status update is requested.
81       */
82      private String key;
83  
84      private StatusRType type;
85  
86      /**
87       * Update token (if required).
88       */
89      private String token;
90  
91      public String getKey() {
92          return key;
93      }
94  
95      @PathParam("key")
96      public void setKey(final String key) {
97          this.key = key;
98      }
99  
100     public StatusRType getType() {
101         return type;
102     }
103 
104     public void setType(final StatusRType type) {
105         this.type = type;
106     }
107 
108     public String getToken() {
109         return token;
110     }
111 
112     public void setToken(final String token) {
113         this.token = token;
114     }
115 
116     @Override
117     public int hashCode() {
118         return new HashCodeBuilder().
119                 appendSuper(super.hashCode()).
120                 append(key).
121                 append(type).
122                 append(token).
123                 build();
124     }
125 
126     @Override
127     public boolean equals(final Object obj) {
128         if (this == obj) {
129             return true;
130         }
131         if (obj == null) {
132             return false;
133         }
134         if (getClass() != obj.getClass()) {
135             return false;
136         }
137         final StatusR other = (StatusR) obj;
138         return new EqualsBuilder().
139                 appendSuper(super.equals(obj)).
140                 append(key, other.key).
141                 append(type, other.type).
142                 append(token, other.token).
143                 build();
144     }
145 }