File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed
src/main/java/org/codehaus/groovy/runtime Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -2795,6 +2795,48 @@ public static int size(final CharSequence self) {
2795
2795
return self .length ();
2796
2796
}
2797
2797
2798
+ /**
2799
+ * Provides a {@code getLength} alias for {@code length} for {@link StringBuilder},
2800
+ * supporting assignment arithmetic operator expressions involving
2801
+ * the otherwise write-only length property.
2802
+ *
2803
+ * <pre class="groovyTestCase">
2804
+ * def sb = new StringBuilder()
2805
+ * sb << 'foobar'
2806
+ * sb.length -= 3
2807
+ * assert sb.toString() == 'foo'
2808
+ * </pre>
2809
+ *
2810
+ * @param self a StringBuilder
2811
+ * @return the length of the StringBuilder
2812
+ *
2813
+ * @since 5.0.0
2814
+ */
2815
+ public static int getLength (final StringBuilder self ) {
2816
+ return self .length ();
2817
+ }
2818
+
2819
+ /**
2820
+ * Provides a {@code getLength} alias for {@code length} for {@link StringBuffer},
2821
+ * supporting assignment arithmetic operator expressions involving
2822
+ * the otherwise write-only length property.
2823
+ *
2824
+ * <pre class="groovyTestCase">
2825
+ * def sb = new StringBuffer()
2826
+ * sb << 'foobar'
2827
+ * sb.length -= 3
2828
+ * assert sb.toString() == 'foo'
2829
+ * </pre>
2830
+ *
2831
+ * @param self a StringBuffer
2832
+ * @return the length of the StringBuffer
2833
+ *
2834
+ * @since 5.0.0
2835
+ */
2836
+ public static int getLength (final StringBuffer self ) {
2837
+ return self .length ();
2838
+ }
2839
+
2798
2840
/**
2799
2841
* Provides the standard Groovy {@code size()} method for {@code Matcher}.
2800
2842
*
You can’t perform that action at this time.
0 commit comments