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.collections;
  17. /**
  18. * Defines a functor interface implemented by classes that transform one
  19. * object into another.
  20. * <p>
  21. * A <code>Transformer</code> converts the input object to the output object.
  22. * The input object should be left unchanged.
  23. * Transformers are typically used for type conversions, or extracting data
  24. * from an object.
  25. * <p>
  26. * Standard implementations of common transformers are provided by
  27. * {@link TransformerUtils}. These include method invokation, returning a constant,
  28. * cloning and returning the string value.
  29. *
  30. * @since Commons Collections 1.0
  31. * @version $Revision: 1.10 $ $Date: 2004/04/14 20:08:57 $
  32. *
  33. * @author James Strachan
  34. * @author Stephen Colebourne
  35. */
  36. public interface Transformer {
  37. /**
  38. * Transforms the input object (leaving it unchanged) into some output object.
  39. *
  40. * @param input the object to be transformed, should be left unchanged
  41. * @return a transformed object
  42. * @throws ClassCastException (runtime) if the input is the wrong class
  43. * @throws IllegalArgumentException (runtime) if the input is invalid
  44. * @throws FunctorException (runtime) if the transform cannot be completed
  45. */
  46. public Object transform(Object input);
  47. }