1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.properties.internal

File DefaultPropertyDescriptor.java

 

Coverage histogram

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

Code metrics

4
26
20
1
243
119
22
0.85
1.3
20
1.1

Classes

Class Line # Actions
DefaultPropertyDescriptor 35 26 0% 22 8
0.8484%
 

Contributing tests

This file is covered by 259 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   
29    /**
30    * Default implementation for {@link PropertyDescriptor}.
31    *
32    * @version $Id: 900db5bfebc68c37a2a026ebbd08d7b2ef4c05a7 $
33    * @since 2.0M2
34    */
 
35    public class DefaultPropertyDescriptor implements PropertyDescriptor
36    {
37    /**
38    * @see #getId()
39    * @since 2.1M1
40    */
41    private String id;
42   
43    /**
44    * @see #getName()
45    * @since 2.1M1
46    */
47    private String name;
48   
49    /**
50    * @see #getDescription()
51    */
52    private String description;
53   
54    /**
55    * @see #getPropertyType()
56    */
57    private Type propertyType;
58   
59    /**
60    * @see #getDefaultValue()
61    */
62    private Object defaultValue;
63   
64    /**
65    * @see #isMandatory()
66    */
67    private boolean mandatory;
68   
69    /**
70    * @see #getFied()
71    */
72    private Field field;
73   
74    /**
75    * @see #getReadMethod()
76    */
77    private Method readMethod;
78   
79    /**
80    * @see #getWriteMethod()
81    */
82    private Method writeMethod;
83   
 
84  416420 toggle @Override
85    public String getId()
86    {
87  416421 return this.id;
88    }
89   
90    /**
91    * @param id the identifier of the property.
92    * @see #getId()
93    * @since 2.1M1
94    */
 
95  5110 toggle public void setId(String id)
96    {
97  5110 this.id = id;
98    }
99   
 
100  21 toggle @Override
101    public String getName()
102    {
103  21 return this.name;
104    }
105   
106    /**
107    * @param name the display name of the property.
108    * @see #getName()
109    * @since 2.1M1
110    */
 
111  5110 toggle public void setName(String name)
112    {
113  5110 this.name = name;
114    }
115   
 
116  30 toggle @Override
117    public String getDescription()
118    {
119  30 return this.description;
120    }
121   
122    /**
123    * @param description the description of the property.
124    * @see #getDescription()
125    */
 
126  5110 toggle public void setDescription(String description)
127    {
128  5110 this.description = description;
129    }
130   
 
131  6 toggle @Override
132    @Deprecated
133    public Class<?> getPropertyClass()
134    {
135  6 Class<?> clazz;
136  6 if (this.propertyType instanceof Class) {
137  6 clazz = (Class) this.propertyType;
138  0 } else if (this.propertyType instanceof ParameterizedType) {
139  0 clazz = (Class) ((ParameterizedType) this.propertyType).getRawType();
140    } else {
141  0 clazz = null;
142    }
143   
144  6 return clazz;
145    }
146   
 
147  5613 toggle @Override
148    public Type getPropertyType()
149    {
150  5613 return this.propertyType;
151    }
152   
153    /**
154    * @param propertyType the class of the property.
155    * @see #getPropertyClass()
156    */
 
157  5110 toggle public void setPropertyType(Type propertyType)
158    {
159  5110 this.propertyType = propertyType;
160    }
161   
 
162  30 toggle @Override
163    public Object getDefaultValue()
164    {
165  30 return this.defaultValue;
166    }
167   
168    /**
169    * @param defaultValue the default value of the property.
170    * @see #getDefaultValue()
171    */
 
172  4898 toggle public void setDefaultValue(Object defaultValue)
173    {
174  4898 this.defaultValue = defaultValue;
175    }
176   
 
177  395273 toggle @Override
178    public boolean isMandatory()
179    {
180  395270 return this.mandatory;
181    }
182   
183    /**
184    * @param mandatory indicate if the property is mandatory.
185    * @see #isMandatory()
186    */
 
187  5110 toggle public void setMandatory(boolean mandatory)
188    {
189  5110 this.mandatory = mandatory;
190    }
191   
192    /**
193    * @see org.xwiki.properties.PropertyDescriptor#getFied().
194    * @param field the {@link Field}.
195    */
 
196  196 toggle public void setField(Field field)
197    {
198  196 this.field = field;
199    }
200   
 
201  0 toggle @Override
202    @Deprecated
203    public Field getFied()
204    {
205  0 return getField();
206    }
207   
 
208  14 toggle @Override
209    public Field getField()
210    {
211  14 return this.field;
212    }
213   
214    /**
215    * @see org.xwiki.properties.PropertyDescriptor#getReadMethod().
216    * @param readMethod the read {@link Method}.
217    */
 
218  4914 toggle public void setReadMethod(Method readMethod)
219    {
220  4914 this.readMethod = readMethod;
221    }
222   
 
223  10 toggle @Override
224    public Method getReadMethod()
225    {
226  10 return this.readMethod;
227    }
228   
229    /**
230    * @see org.xwiki.properties.PropertyDescriptor#getWriteMethod().
231    * @param writeMethod the write {@link Method}.
232    */
 
233  4914 toggle public void setWriteMethod(Method writeMethod)
234    {
235  4914 this.writeMethod = writeMethod;
236    }
237   
 
238  11042 toggle @Override
239    public Method getWriteMethod()
240    {
241  11042 return this.writeMethod;
242    }
243    }