1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.commons.betwixt.strategy;
17
18 /***
19 * <p>Class normalization strategy.</p>
20 *
21 * <p>
22 * The normalized Class is the Class that Betwixt should
23 * introspect.
24 * This strategy class allows the introspected Class to be
25 * varied.
26 * This implementation simply returns the Class given.
27 * </p>
28 *
29 * <p>
30 * Used by Betwixt to allow superclasses or interfaces to be subsittuted
31 * before an object is introspected.
32 * This allows users to feed in logical interfaces and make Betwixt ignore
33 * properties other than those in the interface.
34 * It also allows support for <code>Proxy</code>'s.
35 * Together, these features allow Betwixt to deal with Entity Beans
36 * properly by viewing them through their remote interfaces.
37 * </p>
38 * @author Robert Burrell Donkin
39 * @since 0.5
40 */
41 public class ClassNormalizer {
42
43 /***
44 * Gets the normalized class for the given Object.
45 * The normalized Class is the Class that Betwixt should
46 * introspect.
47 * This strategy class allows the introspected Class to be
48 * varied.
49 *
50 * @param object the <code>Object</code>
51 * for which the normalized Class is to be returned.
52 * @return the normalized Class
53 */
54 public Class getNormalizedClass( Object object ) {
55 if ( object == null ) {
56 throw new IllegalArgumentException("Cannot get class for null object.");
57 }
58 return normalize( object.getClass() );
59 }
60
61 /***
62 * Normalize given class.
63 * The normalized Class is the Class that Betwixt should
64 * introspect.
65 * This strategy class allows the introspected Class to be
66 * varied.
67 *
68 * @param clazz the class to normalize, not null
69 * @return this implementation the same clazz,
70 * subclasses may return any compatible class.
71 */
72 public Class normalize( Class clazz ) {
73 return clazz;
74 }
75 }