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 com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
22  import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
23  import java.util.ArrayList;
24  import java.util.List;
25  import org.apache.commons.lang3.builder.EqualsBuilder;
26  import org.apache.commons.lang3.builder.HashCodeBuilder;
27  import org.apache.syncope.common.lib.BaseBean;
28  
29  public class ConnConfPropSchema implements BaseBean, Comparable<ConnConfPropSchema> {
30  
31      private static final long serialVersionUID = -1976365781005801296L;
32  
33      private String name;
34  
35      private String displayName;
36  
37      private String helpMessage;
38  
39      private String type = String.class.getName();
40  
41      private boolean required;
42  
43      private int order;
44  
45      private boolean confidential;
46  
47      private final List<Object> defaultValues = new ArrayList<>();
48  
49      public String getName() {
50          return name;
51      }
52  
53      public void setName(final String name) {
54          this.name = name;
55      }
56  
57      public boolean isRequired() {
58          return required;
59      }
60  
61      public void setRequired(final boolean required) {
62          this.required = required;
63      }
64  
65      public String getType() {
66          return type;
67      }
68  
69      public void setType(final String type) {
70          this.type = type;
71      }
72  
73      public String getDisplayName() {
74          return displayName;
75      }
76  
77      public void setDisplayName(final String displayName) {
78          this.displayName = displayName;
79      }
80  
81      public String getHelpMessage() {
82          return helpMessage;
83      }
84  
85      public void setHelpMessage(final String helpMessage) {
86          this.helpMessage = helpMessage;
87      }
88  
89      public int getOrder() {
90          return order;
91      }
92  
93      public void setOrder(final int order) {
94          this.order = order;
95      }
96  
97      public boolean isConfidential() {
98          return confidential;
99      }
100 
101     public void setConfidential(final boolean confidential) {
102         this.confidential = confidential;
103     }
104 
105     @JacksonXmlElementWrapper(localName = "defaultValues")
106     @JacksonXmlProperty(localName = "defaultValue")
107     public List<Object> getDefaultValues() {
108         return defaultValues;
109     }
110 
111     @Override
112     public int compareTo(final ConnConfPropSchema other) {
113         return this.getOrder() > other.getOrder()
114                 ? 1
115                 : this.getOrder() < other.getOrder()
116                 ? -1
117                 : 0;
118     }
119 
120     @Override
121     public int hashCode() {
122         return new HashCodeBuilder().
123                 append(name).
124                 append(type).
125                 append(required).
126                 append(order).
127                 append(confidential).
128                 build();
129     }
130 
131     @Override
132     public boolean equals(final Object obj) {
133         if (this == obj) {
134             return true;
135         }
136         if (obj == null) {
137             return false;
138         }
139         if (getClass() != obj.getClass()) {
140             return false;
141         }
142         final ConnConfPropSchema other = (ConnConfPropSchema) obj;
143         return new EqualsBuilder().
144                 append(name, other.name).
145                 append(type, other.type).
146                 append(required, other.required).
147                 append(order, other.order).
148                 append(confidential, other.confidential).
149                 build();
150     }
151 }