01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
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(
58: "Cannot get class for null object.");
59: }
60: return normalize(object.getClass());
61: }
62:
63: /**
64: * Normalize given class.
65: * The normalized Class is the Class that Betwixt should
66: * introspect.
67: * This strategy class allows the introspected Class to be
68: * varied.
69: *
70: * @param clazz the class to normalize, not null
71: * @return this implementation the same clazz,
72: * subclasses may return any compatible class.
73: */
74: public Class normalize(Class clazz) {
75: return clazz;
76: }
77: }
|