1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * 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.collections;
18
19 /**
20 * Defines a functor interface implemented by classes that transform one
21 * object into another.
22 * <p>
23 * A <code>Transformer</code> converts the input object to the output object.
24 * The input object should be left unchanged.
25 * Transformers are typically used for type conversions, or extracting data
26 * from an object.
27 * <p>
28 * Standard implementations of common transformers are provided by
29 * {@link TransformerUtils}. These include method invokation, returning a constant,
30 * cloning and returning the string value.
31 *
32 * @param <I> the input type to the transformer
33 * @param <O> the output type from the transformer
34 *
35 * @since 1.0
36 * @version $Id: Transformer.java 1361710 2012-07-15 15:00:21Z tn $
37 */
38 public interface Transformer<I, O> {
39
40 /**
41 * Transforms the input object (leaving it unchanged) into some output object.
42 *
43 * @param input the object to be transformed, should be left unchanged
44 * @return a transformed object
45 * @throws ClassCastException (runtime) if the input is the wrong class
46 * @throws IllegalArgumentException (runtime) if the input is invalid
47 * @throws FunctorException (runtime) if the transform cannot be completed
48 */
49 public O transform(I input);
50
51 }