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