1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.commons.betwixt.strategy;
17
18 import java.util.Collection;
19
20 /***
21 * Pluggable strategy specifying whether property's should be surpressed.
22 * Implementations can be used to give rules about which properties
23 * should be ignored by Betwixt when introspecting.
24 * @since 0.7
25 * @author <a href='http://jakarta.apache.org/commons'>Jakarta Commons Team</a>, <a href='http://www.apache.org'>Apache Software Foundation</a>
26 */
27 public abstract class PropertySuppressionStrategy {
28
29 /***
30 * Default implementation supresses the class property
31 * found on every object. Also, the <code>isEmpty</code>
32 * property is supressed for implementations of <code>Collection</code>.
33 */
34 public static final PropertySuppressionStrategy DEFAULT = new PropertySuppressionStrategy() {
35 public boolean suppressProperty(Class clazz, Class propertyType, String propertyName) {
36 boolean result = false;
37
38 if ( Class.class.equals( propertyType) && "class".equals( propertyName ) ) {
39 result = true;
40 }
41
42 if ( "empty".equals( propertyName ) && Collection.class.isAssignableFrom( clazz )) {
43 result = true;
44 }
45
46 return result;
47 }
48 };
49
50 /***
51 * Should the given property be suppressed?
52 * @param classContainingTheProperty <code>Class</code> giving the type of the bean containing the property <code>propertyName</code>
53 * @param propertyType <code>Class</code> giving the type of the property, not null
54 * @param propertyName the name of the property, not null
55 * @return true when the given property should be suppressed
56 */
57 public abstract boolean suppressProperty(Class classContainingTheProperty, Class propertyType, String propertyName);
58 }