1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package net.sf.oness.common.model.bo;
17
18 import java.lang.reflect.Field;
19
20 import net.sf.oness.common.all.ReflectionToStringBuilder;
21 import net.sf.oness.common.model.util.CollectionUtils;
22
23 /***
24 * Customized ReflectionToStringBuilder ignoring Collection fields.
25 *
26 * @see org.apache.commons.lang.builder.ReflectionToStringBuilder
27 *
28 * @author Carlos Sanchez
29 * @version $Revision: 1.2 $
30 */
31 public class CollectionIgnoringReflectionToStringBuilder extends
32 ReflectionToStringBuilder {
33
34 public CollectionIgnoringReflectionToStringBuilder(Object object) {
35 super(object);
36 }
37
38 /***
39 * Check if the field is a collection and return false in that case.
40 *
41 * @see org.apache.commons.lang.builder.ReflectionToStringBuilder#accept(java.lang.reflect.Field)
42 */
43 protected boolean accept(Field field) {
44 if (CollectionUtils.isCollection(field.getType()))
45 return false;
46 return super.accept(field);
47 }
48 }