1. /*
  2. * Copyright 2001-2004 The Apache Software Foundation.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package org.apache.commons.betwixt.strategy;
  17. /**
  18. * <p>Class normalization strategy.</p>
  19. *
  20. * <p>
  21. * The normalized Class is the Class that Betwixt should
  22. * introspect.
  23. * This strategy class allows the introspected Class to be
  24. * varied.
  25. * This implementation simply returns the Class given.
  26. * </p>
  27. *
  28. * <p>
  29. * Used by Betwixt to allow superclasses or interfaces to be subsittuted
  30. * before an object is introspected.
  31. * This allows users to feed in logical interfaces and make Betwixt ignore
  32. * properties other than those in the interface.
  33. * It also allows support for <code>Proxy</code>'s.
  34. * Together, these features allow Betwixt to deal with Entity Beans
  35. * properly by viewing them through their remote interfaces.
  36. * </p>
  37. * @author Robert Burrell Donkin
  38. * @since 0.5
  39. */
  40. public class ClassNormalizer {
  41. /**
  42. * Gets the normalized class for the given Object.
  43. * The normalized Class is the Class that Betwixt should
  44. * introspect.
  45. * This strategy class allows the introspected Class to be
  46. * varied.
  47. *
  48. * @param object the <code>Object</code>
  49. * for which the normalized Class is to be returned.
  50. * @return the normalized Class
  51. */
  52. public Class getNormalizedClass( Object object ) {
  53. if ( object == null ) {
  54. throw new IllegalArgumentException("Cannot get class for null object.");
  55. }
  56. return normalize( object.getClass() );
  57. }
  58. /**
  59. * Normalize given class.
  60. * The normalized Class is the Class that Betwixt should
  61. * introspect.
  62. * This strategy class allows the introspected Class to be
  63. * varied.
  64. *
  65. * @param clazz the class to normalize, not null
  66. * @return this implementation the same clazz,
  67. * subclasses may return any compatible class.
  68. */
  69. public Class normalize( Class clazz ) {
  70. return clazz;
  71. }
  72. }