1
2
3
4
5
6
7
8
9
10
11
12
13
14
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 whose {@link #transform} method
24 * returns the result of <code>String.valueOf(input)</code>, where
25 * <code>input</code> is the input object.
26 *
27 * @author Stephen Colebourne
28 * @author Chris Lambrou (port to Java 5.0)
29 * @since Collections15 1.0
30 */
31 public final class StringValueTransformer <E> implements Transformer<E, String>, Serializable
32 {
33
34 static final long serialVersionUID = 957699420306662351L;
35
36 /***
37 * Returns a new instance.
38 *
39 * @return A new instance.
40 *
41 * @since Collections15 1.0
42 */
43 public static <E> Transformer<E, String> getInstance()
44 {
45 return new StringValueTransformer<E>();
46 }
47
48 /***
49 * Creates a new instance.
50 */
51 protected StringValueTransformer()
52 {
53 }
54
55 /***
56 * Transforms the input by returning the result of <code>String.valueOf(input)</code>.
57 *
58 * @param input The input object to transform.
59 *
60 * @return The string value of the input.
61 */
62 public String transform(E input)
63 {
64 return String.valueOf(input);
65 }
66
67 }