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 java.util.LinkedHashMap;
22  import java.util.Map;
23  import java.util.regex.Pattern;
24  import org.apache.commons.lang3.builder.EqualsBuilder;
25  import org.apache.commons.lang3.builder.HashCodeBuilder;
26  import org.apache.syncope.common.lib.form.FormPropertyType;
27  
28  public class FormPropertyDefTO implements NamedEntityTO {
29  
30      private static final long serialVersionUID = -6862109424380661428L;
31  
32      private String key;
33  
34      private String name;
35  
36      private FormPropertyType type;
37  
38      private boolean readable = true;
39  
40      private boolean writable = true;
41  
42      private boolean required;
43  
44      private Pattern stringRegEx;
45  
46      private String datePattern;
47  
48      private final Map<String, String> enumValues = new LinkedHashMap<>();
49  
50      private boolean dropdownSingleSelection = true;
51  
52      private boolean dropdownFreeForm;
53  
54      @Override
55      public String getKey() {
56          return key;
57      }
58  
59      @Override
60      public void setKey(final String key) {
61          this.key = key;
62      }
63  
64      @Override
65      public String getName() {
66          return name;
67      }
68  
69      @Override
70      public void setName(final String name) {
71          this.name = name;
72      }
73  
74      public FormPropertyType getType() {
75          return type;
76      }
77  
78      public void setType(final FormPropertyType type) {
79          this.type = type;
80      }
81  
82      public boolean isReadable() {
83          return readable;
84      }
85  
86      public void setReadable(final boolean readable) {
87          this.readable = readable;
88      }
89  
90      public boolean isWritable() {
91          return writable;
92      }
93  
94      public void setWritable(final boolean writable) {
95          this.writable = writable;
96      }
97  
98      public boolean isRequired() {
99          return required;
100     }
101 
102     public void setRequired(final boolean required) {
103         this.required = required;
104     }
105 
106     public Pattern getStringRegEx() {
107         return stringRegEx;
108     }
109 
110     public void setStringRegEx(final Pattern stringRegEx) {
111         this.stringRegEx = stringRegEx;
112     }
113 
114     public String getDatePattern() {
115         return datePattern;
116     }
117 
118     public void setDatePattern(final String datePattern) {
119         this.datePattern = datePattern;
120     }
121 
122     public Map<String, String> getEnumValues() {
123         return enumValues;
124     }
125 
126     public boolean isDropdownSingleSelection() {
127         return dropdownSingleSelection;
128     }
129 
130     public void setDropdownSingleSelection(final boolean dropdownSingleSelection) {
131         this.dropdownSingleSelection = dropdownSingleSelection;
132     }
133 
134     public boolean isDropdownFreeForm() {
135         return dropdownFreeForm;
136     }
137 
138     public void setDropdownFreeForm(final boolean dropdownFreeForm) {
139         this.dropdownFreeForm = dropdownFreeForm;
140     }
141 
142     @Override
143     public int hashCode() {
144         return new HashCodeBuilder().
145                 append(key).
146                 append(name).
147                 append(type).
148                 append(readable).
149                 append(writable).
150                 append(required).
151                 append(stringRegEx).
152                 append(datePattern).
153                 append(enumValues).
154                 append(dropdownSingleSelection).
155                 append(dropdownFreeForm).
156                 build();
157     }
158 
159     @Override
160     public boolean equals(final Object obj) {
161         if (this == obj) {
162             return true;
163         }
164         if (obj == null) {
165             return false;
166         }
167         if (getClass() != obj.getClass()) {
168             return false;
169         }
170         FormPropertyDefTO other = (FormPropertyDefTO) obj;
171         return new EqualsBuilder().
172                 append(key, other.key).
173                 append(name, other.name).
174                 append(type, other.type).
175                 append(readable, other.readable).
176                 append(writable, other.writable).
177                 append(required, other.required).
178                 append(stringRegEx, other.stringRegEx).
179                 append(datePattern, other.datePattern).
180                 append(enumValues, other.enumValues).
181                 append(dropdownSingleSelection, other.dropdownSingleSelection).
182                 append(dropdownFreeForm, other.dropdownFreeForm).
183                 build();
184     }
185 }