View Javadoc

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 net.sf.collections15.functors.transformer;
17  
18  import net.sf.collections15.Transformer;
19  
20  import java.io.Serializable;
21  
22  /***
23   * <code>Transformer</code> implementation that does nothing.
24   *
25   * @author Stephen Colebourne
26   * @author Chris Lambrou (port to Java 5.0)
27   * @since Collections15 1.0
28   */
29  public class NOPTransformer <E> implements Transformer<E, E>, Serializable
30  {
31  
32      static final long serialVersionUID = 5564713373493429325L;
33  
34      /***
35       * Returns an instance of <code>NOPTransformer</code>.
36       *
37       * @return An instance of <code>NOPTransformer</code>.
38       *
39       * @since Collections15 1.0
40       */
41      public static <T> NOPTransformer<T> getInstance()
42      {
43          return new NOPTransformer<T>();
44      }
45  
46      /***
47       * Creates a new instance.
48       */
49      protected NOPTransformer()
50      {
51      }
52  
53      /***
54       * Transforms the input to result by doing nothing.
55       *
56       * @param input The input object to transform.
57       *
58       * @return The input object.
59       */
60      public E transform(E input)
61      {
62          return input;
63      }
64  
65  }