1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package org.xwiki.properties.internal

File DefaultPropertyDescriptor.java

 

Coverage histogram

../../../../img/srcFileCovDistChart9.png
41% of files have more coverage

Code metrics

4
34
28
1
328
160
30
0.88
1.21
28
1.07

Classes

Class Line # Actions
DefaultPropertyDescriptor 36 34 0% 30 8
0.878787987.9%
 

Contributing tests

This file is covered by 288 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.properties.internal;
21   
22    import java.lang.reflect.Field;
23    import java.lang.reflect.Method;
24    import java.lang.reflect.ParameterizedType;
25    import java.lang.reflect.Type;
26   
27    import org.xwiki.properties.PropertyDescriptor;
28    import org.xwiki.properties.PropertyGroupDescriptor;
29   
30    /**
31    * Default implementation for {@link PropertyDescriptor}.
32    *
33    * @version $Id: 23f2e2970b9a5396cf98551d77c5e9465ce2e232 $
34    * @since 2.0M2
35    */
 
36    public class DefaultPropertyDescriptor implements PropertyDescriptor
37    {
38    /**
39    * @see #getId()
40    * @since 2.1M1
41    */
42    private String id;
43   
44    /**
45    * @see #getName()
46    * @since 2.1M1
47    */
48    private String name;
49   
50    /**
51    * @see #getDescription()
52    */
53    private String description;
54   
55    /**
56    * @see #getPropertyType()
57    */
58    private Type propertyType;
59   
60    /**
61    * @see #getDefaultValue()
62    */
63    private Object defaultValue;
64   
65    /**
66    * @see #isMandatory()
67    */
68    private boolean mandatory;
69   
70    /**
71    * @see #getFied()
72    */
73    private Field field;
74   
75    /**
76    * @see #getReadMethod()
77    */
78    private Method readMethod;
79   
80    /**
81    * @see #getWriteMethod()
82    */
83    private Method writeMethod;
84   
85    /**
86    * @see #isDeprecated()
87    */
88    private boolean deprecated;
89   
90    /**
91    * @see #isAdvanced()
92    */
93    private boolean advanced;
94   
95    /**
96    * @see #getGroupDescriptor()
97    */
98    private PropertyGroupDescriptor groupDescriptor;
99   
100    /**
101    * @see #getDisplayType()
102    */
103    private Type displayType;
104   
 
105  4993483 toggle @Override
106    public String getId()
107    {
108  4993795 return this.id;
109    }
110   
111    /**
112    * @param id the identifier of the property.
113    * @see #getId()
114    * @since 2.1M1
115    */
 
116  6555 toggle public void setId(String id)
117    {
118  6555 this.id = id;
119    }
120   
 
121  21 toggle @Override
122    public String getName()
123    {
124  21 return this.name;
125    }
126   
127    /**
128    * @param name the display name of the property.
129    * @see #getName()
130    * @since 2.1M1
131    */
 
132  6555 toggle public void setName(String name)
133    {
134  6555 this.name = name;
135    }
136   
 
137  30 toggle @Override
138    public String getDescription()
139    {
140  30 return this.description;
141    }
142   
143    /**
144    * @param description the description of the property.
145    * @see #getDescription()
146    */
 
147  6555 toggle public void setDescription(String description)
148    {
149  6555 this.description = description;
150    }
151   
 
152  6 toggle @Override
153    @Deprecated
154    public Class<?> getPropertyClass()
155    {
156  6 Class<?> clazz;
157  6 if (this.propertyType instanceof Class) {
158  6 clazz = (Class) this.propertyType;
159  0 } else if (this.propertyType instanceof ParameterizedType) {
160  0 clazz = (Class) ((ParameterizedType) this.propertyType).getRawType();
161    } else {
162  0 clazz = null;
163    }
164   
165  6 return clazz;
166    }
167   
 
168  252982 toggle @Override
169    public Type getPropertyType()
170    {
171  252983 return this.propertyType;
172    }
173   
174    /**
175    * @param propertyType the class of the property.
176    * @see #getPropertyClass()
177    */
 
178  6555 toggle public void setPropertyType(Type propertyType)
179    {
180  6555 this.propertyType = propertyType;
181    }
182   
 
183  30 toggle @Override
184    public Object getDefaultValue()
185    {
186  30 return this.defaultValue;
187    }
188   
189    /**
190    * @param defaultValue the default value of the property.
191    * @see #getDefaultValue()
192    */
 
193  6244 toggle public void setDefaultValue(Object defaultValue)
194    {
195  6244 this.defaultValue = defaultValue;
196    }
197   
 
198  4726942 toggle @Override
199    public boolean isMandatory()
200    {
201  4727118 return this.mandatory;
202    }
203   
204    /**
205    * @param mandatory indicate if the property is mandatory.
206    * @see #isMandatory()
207    */
 
208  6555 toggle public void setMandatory(boolean mandatory)
209    {
210  6555 this.mandatory = mandatory;
211    }
212   
213    /**
214    * @see org.xwiki.properties.PropertyDescriptor#getFied().
215    * @param field the {@link Field}.
216    */
 
217  236 toggle public void setField(Field field)
218    {
219  236 this.field = field;
220    }
221   
 
222  0 toggle @Override
223    @Deprecated
224    public Field getFied()
225    {
226  0 return getField();
227    }
228   
 
229  58 toggle @Override
230    public Field getField()
231    {
232  58 return this.field;
233    }
234   
235    /**
236    * @see org.xwiki.properties.PropertyDescriptor#getReadMethod().
237    * @param readMethod the read {@link Method}.
238    */
 
239  6318 toggle public void setReadMethod(Method readMethod)
240    {
241  6318 this.readMethod = readMethod;
242    }
243   
 
244  10 toggle @Override
245    public Method getReadMethod()
246    {
247  10 return this.readMethod;
248    }
249   
250    /**
251    * @see org.xwiki.properties.PropertyDescriptor#getWriteMethod().
252    * @param writeMethod the write {@link Method}.
253    */
 
254  6318 toggle public void setWriteMethod(Method writeMethod)
255    {
256  6318 this.writeMethod = writeMethod;
257    }
258   
 
259  492685 toggle @Override
260    public Method getWriteMethod()
261    {
262  492696 return this.writeMethod;
263    }
264   
 
265  3 toggle @Override
266    public boolean isDeprecated()
267    {
268  3 return this.deprecated;
269    }
270   
271    /**
272    * @param deprecated indicates if the parameter is deprecated
273    * @see #isDeprecated()
274    * @since 10.10RC1
275    */
 
276  6555 toggle public void setDeprecated(boolean deprecated)
277    {
278  6555 this.deprecated = deprecated;
279    }
280   
 
281  3 toggle @Override
282    public boolean isAdvanced()
283    {
284  3 return this.advanced;
285    }
286   
287    /**
288    * @param advanced indicates if the parameter is advanced
289    * @see #isAdvanced()
290    * @since 10.10RC1
291    */
 
292  6555 toggle public void setAdvanced(boolean advanced)
293    {
294  6555 this.advanced = advanced;
295    }
296   
 
297  13 toggle @Override
298    public PropertyGroupDescriptor getGroupDescriptor()
299    {
300  13 return this.groupDescriptor;
301    }
302   
303    /**
304    * @param groupDescriptor the hierarchy of groups
305    * @see #getGroupDescriptor()
306    * @since 10.11RC1
307    */
 
308  6555 toggle public void setGroupDescriptor(PropertyGroupDescriptor groupDescriptor)
309    {
310  6555 this.groupDescriptor = groupDescriptor;
311    }
312   
 
313  4 toggle @Override
314    public Type getDisplayType()
315    {
316  4 return this.displayType;
317    }
318   
319    /**
320    * @param displayType the type used when displaying the property.
321    * @see #getDisplayType()
322    * @since 11.0
323    */
 
324  6554 toggle public void setDisplayType(Type displayType)
325    {
326  6554 this.displayType = displayType;
327    }
328    }