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.to;
20  
21  import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
22  import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
23  import java.io.Serializable;
24  import java.util.ArrayList;
25  import java.util.List;
26  import org.apache.commons.lang3.builder.EqualsBuilder;
27  import org.apache.commons.lang3.builder.HashCodeBuilder;
28  import org.apache.syncope.common.lib.types.UserRequestFormPropertyType;
29  
30  public class UserRequestFormProperty implements Serializable {
31  
32      private static final long serialVersionUID = 9139969592634304261L;
33  
34      private String id;
35  
36      private String name;
37  
38      private UserRequestFormPropertyType type;
39  
40      private boolean readable;
41  
42      private boolean writable;
43  
44      private boolean required;
45  
46      private String datePattern;
47  
48      private final List<UserRequestFormPropertyValue> enumValues = new ArrayList<>();
49  
50      private final List<UserRequestFormPropertyValue> dropdownValues = new ArrayList<>();
51  
52      private String value;
53  
54      public String getId() {
55          return id;
56      }
57  
58      public void setId(final String id) {
59          this.id = id;
60      }
61  
62      public String getName() {
63          return name;
64      }
65  
66      public void setName(final String name) {
67          this.name = name;
68      }
69  
70      public boolean isReadable() {
71          return readable;
72      }
73  
74      public void setReadable(final boolean readable) {
75          this.readable = readable;
76      }
77  
78      public boolean isRequired() {
79          return required;
80      }
81  
82      public void setRequired(final boolean required) {
83          this.required = required;
84      }
85  
86      public UserRequestFormPropertyType getType() {
87          return type;
88      }
89  
90      public void setType(final UserRequestFormPropertyType type) {
91          this.type = type;
92      }
93  
94      public boolean isWritable() {
95          return writable;
96      }
97  
98      public void setWritable(final boolean writable) {
99          this.writable = writable;
100     }
101 
102     public String getDatePattern() {
103         return datePattern;
104     }
105 
106     public void setDatePattern(final String datePattern) {
107         this.datePattern = datePattern;
108     }
109 
110     @JacksonXmlElementWrapper(localName = "enumValues")
111     @JacksonXmlProperty(localName = "enumValue")
112     public List<UserRequestFormPropertyValue> getEnumValues() {
113         return enumValues;
114     }
115 
116     @JacksonXmlElementWrapper(localName = "dropdownValues")
117     @JacksonXmlProperty(localName = "dropdownValue")
118     public List<UserRequestFormPropertyValue> getDropdownValues() {
119         return dropdownValues;
120     }
121 
122     public String getValue() {
123         return value;
124     }
125 
126     public void setValue(final String value) {
127         this.value = value;
128     }
129 
130     @Override
131     public int hashCode() {
132         return new HashCodeBuilder().
133                 append(id).
134                 append(name).
135                 append(type).
136                 append(readable).
137                 append(writable).
138                 append(required).
139                 append(datePattern).
140                 append(enumValues).
141                 append(dropdownValues).
142                 append(value).
143                 build();
144     }
145 
146     @Override
147     public boolean equals(final Object obj) {
148         if (this == obj) {
149             return true;
150         }
151         if (obj == null) {
152             return false;
153         }
154         if (getClass() != obj.getClass()) {
155             return false;
156         }
157         UserRequestFormProperty other = (UserRequestFormProperty) obj;
158         return new EqualsBuilder().
159                 append(id, other.id).
160                 append(name, other.name).
161                 append(type, other.type).
162                 append(readable, other.readable).
163                 append(writable, other.writable).
164                 append(required, other.required).
165                 append(datePattern, other.datePattern).
166                 append(enumValues, other.enumValues).
167                 append(dropdownValues, other.dropdownValues).
168                 append(value, other.value).
169                 build();
170     }
171 }