MCPcopy Create free account
hub / github.com/apache/groovy / GString

Class GString

src/main/java/groovy/lang/GString.java:40–299  ·  view source on GitHub ↗

Represents a String which contains embedded values such as "hello there ${user} how are you?" which can be evaluated lazily. Advanced users can iterate over the text and values to perform special processing, such as for performing SQL operations, the values can be substituted for ? and the actual va

Source from the content-addressed store, hash-verified

38 * and was such a good idea, I couldn't resist :)
39 */
40public abstract class GString extends GroovyObjectSupport implements Comparable, CharSequence, Writable, Buildable, Serializable {
41
42 @Serial private static final long serialVersionUID = -2638020355892246323L;
43
44 /**
45 * Shared empty string array.
46 */
47 public static final String[] EMPTY_STRING_ARRAY = new String[0];
48
49 /**
50 * Shared empty object array.
51 */
52 public static final Object[] EMPTY_OBJECT_ARRAY = new Object[0];
53
54 /**
55 * A GString containing a single empty String and no values.
56 */
57 public static final GString EMPTY = new GString(EMPTY_OBJECT_ARRAY) {
58 @Serial private static final long serialVersionUID = -7676746462783374250L;
59 private static final String EMPTY_STRING = "";
60
61 /**
62 * {@inheritDoc}
63 */
64 @Override
65 public String[] getStrings() {
66 return new String[]{EMPTY_STRING};
67 }
68
69 /**
70 * {@inheritDoc}
71 */
72 @Override
73 public String toString() {
74 return EMPTY_STRING;
75 }
76 };
77
78 private final Object[] values;
79
80 /**
81 * Creates a GString from the supplied values array reference.
82 *
83 * @param values the interpolated values
84 */
85 public GString(Object values) {
86 this.values = (Object[]) values;
87 }
88
89 /**
90 * Creates a GString from the supplied values.
91 *
92 * @param values the interpolated values
93 */
94 public GString(Object[] values) {
95 this.values = values;
96 }
97

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected