Details

    • Type: Task Task
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.0
    • Component/s: General
    • Labels:
      None

      Description

      Which methods are good candidates for varargs.

        Issue Links

          Activity

          Hide
          Richard Wheeldon added a comment -

          Short java file showing method signatures for candidates for varargs.

          Show
          Richard Wheeldon added a comment - Short java file showing method signatures for candidates for varargs.
          Hide
          James Carman added a comment -

          I can tackle these if nobody else has already started.

          Show
          James Carman added a comment - I can tackle these if nobody else has already started.
          Hide
          James Carman added a comment -

          Since we're not terribly concerned with backward compatibility, can we rearrange parameters so that varargs works? Are we planning on renaming the packages?

          Show
          James Carman added a comment - Since we're not terribly concerned with backward compatibility, can we rearrange parameters so that varargs works? Are we planning on renaming the packages?
          Hide
          Henri Yandell added a comment -

          Feel free to rearrange. Document the rearranging here.

          We'll do a clirr/jardiff comparison and decide on renaming later. If there's not enough of a delta we can unrearrange, or we can change packages.

          Show
          Henri Yandell added a comment - Feel free to rearrange. Document the rearranging here. We'll do a clirr/jardiff comparison and decide on renaming later. If there's not enough of a delta we can unrearrange, or we can change packages.
          Hide
          Henri Yandell added a comment -

          NumberUtils.min, NumberUtils.max varargs runs into the no overloading recommendation:

          src/test/org/apache/commons/lang/math/NumberUtilsTest.java:[1175,42] reference to max is ambiguous, both method max(double...) in org.apache.commons.lang.math.NumberUtils and method max(float...) in org.apache.commons.lang.math.NumberUtils match

          Show
          Henri Yandell added a comment - NumberUtils.min, NumberUtils.max varargs runs into the no overloading recommendation: src/test/org/apache/commons/lang/math/NumberUtilsTest.java: [1175,42] reference to max is ambiguous, both method max(double...) in org.apache.commons.lang.math.NumberUtils and method max(float...) in org.apache.commons.lang.math.NumberUtils match
          Hide
          Henri Yandell added a comment -

          The invokeMethod's on MethodUtils should be moved to varargs to match the underlying API in 1.5.

          Show
          Henri Yandell added a comment - The invokeMethod's on MethodUtils should be moved to varargs to match the underlying API in 1.5.
          Hide
          Henri Yandell added a comment -

          DateUtils.parseDate should take a vararg String... of patterns.

          Show
          Henri Yandell added a comment - DateUtils.parseDate should take a vararg String... of patterns.
          Hide
          Henri Yandell added a comment -

          MethodUtils methods vararg'd.

          Show
          Henri Yandell added a comment - MethodUtils methods vararg'd.
          Hide
          Henri Yandell added a comment -

          DateUtils.parseDate also vararg'd.

          Show
          Henri Yandell added a comment - DateUtils.parseDate also vararg'd.
          Hide
          Henri Yandell added a comment -

          svn ci -m "Vararging more methods. StringUtils.getCommonPrefix, StringUtils.indexOfDifference, WordUtils.initials, WordUtils.uncapitalize, WordUtils.capitalizeFully, WordUtils.capitalize, BooleanUtils.xor. LANG-396" src/
          Sending src/main/java/org/apache/commons/lang3/BooleanUtils.java
          Sending src/main/java/org/apache/commons/lang3/StringUtils.java
          Sending src/main/java/org/apache/commons/lang3/text/WordUtils.java
          Transmitting file data ...
          Committed revision 925967.

          Show
          Henri Yandell added a comment - svn ci -m "Vararging more methods. StringUtils.getCommonPrefix, StringUtils.indexOfDifference, WordUtils.initials, WordUtils.uncapitalize, WordUtils.capitalizeFully, WordUtils.capitalize, BooleanUtils.xor. LANG-396 " src/ Sending src/main/java/org/apache/commons/lang3/BooleanUtils.java Sending src/main/java/org/apache/commons/lang3/StringUtils.java Sending src/main/java/org/apache/commons/lang3/text/WordUtils.java Transmitting file data ... Committed revision 925967.
          Hide
          Henri Yandell added a comment -

          svn ci -m "Vararging constructor methods; much like the method ones were in MethodUtils. LANG-396" src/
          Sending src/main/java/org/apache/commons/lang3/reflect/ConstructorUtils.java
          Transmitting file data .
          Committed revision 925970.

          Show
          Henri Yandell added a comment - svn ci -m "Vararging constructor methods; much like the method ones were in MethodUtils. LANG-396 " src/ Sending src/main/java/org/apache/commons/lang3/reflect/ConstructorUtils.java Transmitting file data . Committed revision 925970.
          Hide
          Henri Yandell added a comment -

          Possible solution to the NumberUtils problem would be to split them off as FloatUtils, DoubleUtils etc.

          Show
          Henri Yandell added a comment - Possible solution to the NumberUtils problem would be to split them off as FloatUtils, DoubleUtils etc.
          Hide
          Henri Yandell added a comment -

          Note that some of the methods in Richard's patch were new methods rather than modifications.

          Show
          Henri Yandell added a comment - Note that some of the methods in Richard's patch were new methods rather than modifications.
          Hide
          Henri Yandell added a comment -

          Remaining possibilities seem to just be in StringUtils now:

          While it might make sense for the first, it would be confusing for the second. Skip.

          public static String[] stripAll(String[] strs);
          public static String[] stripAll(String[] strs, String stripChars);

          Generally all the same type, the char[]/String[] could be vararged, but isn't a great fit.

          public static int indexOfAny(CharSequence cs, char[] searchChars);
          public static boolean containsAny(String cs, char[] searchChars);
          public static int indexOfAnyBut(CharSequence cs, char[] searchChars);
          public static boolean containsOnly(CharSequence cs, char[] valid);
          public static boolean containsNone(CharSequence cs, char[] searchChars);
          public static int indexOfAny(String str, String[] searchStrs);
          public static int lastIndexOfAny(String str, String[] searchStrs);
          public static boolean startsWithAny(String string, String[] searchStrings);

          The join method itself would be great to have vararg'd, but the other options will get in its way. Reversing the parameters won't help with the desire for a join(Object... elements) API.

          public static String join(Object[] array);
          public static String join(Object[] array, char separator);
          public static String join(Object[] array, char separator, int startIndex, int endIndex);
          public static String join(Object[] array, String separator);
          public static String join(Object[] array, String separator, int startIndex, int endIndex);

          A new method should solve that. We removed the deprecated concatenate method; with String.concat now existing I think we can bring in a StringUtils.concat(Object... elements) method. Also tempting to add a StringUtils.concatWith(String separator, Object... elements) method.

          Show
          Henri Yandell added a comment - Remaining possibilities seem to just be in StringUtils now: — While it might make sense for the first, it would be confusing for the second. Skip. public static String[] stripAll(String[] strs); public static String[] stripAll(String[] strs, String stripChars); — Generally all the same type, the char[]/String[] could be vararged, but isn't a great fit. public static int indexOfAny(CharSequence cs, char[] searchChars); public static boolean containsAny(String cs, char[] searchChars); public static int indexOfAnyBut(CharSequence cs, char[] searchChars); public static boolean containsOnly(CharSequence cs, char[] valid); public static boolean containsNone(CharSequence cs, char[] searchChars); public static int indexOfAny(String str, String[] searchStrs); public static int lastIndexOfAny(String str, String[] searchStrs); public static boolean startsWithAny(String string, String[] searchStrings); — The join method itself would be great to have vararg'd, but the other options will get in its way. Reversing the parameters won't help with the desire for a join(Object... elements) API. public static String join(Object[] array); public static String join(Object[] array, char separator); public static String join(Object[] array, char separator, int startIndex, int endIndex); public static String join(Object[] array, String separator); public static String join(Object[] array, String separator, int startIndex, int endIndex); A new method should solve that. We removed the deprecated concatenate method; with String.concat now existing I think we can bring in a StringUtils.concat(Object... elements) method. Also tempting to add a StringUtils.concatWith(String separator, Object... elements) method.
          Hide
          Henri Yandell added a comment -

          svn ci -m "Adding concat(Object...) and concatWith(String, Object...) methods to provide vararg'd versions of the more prominent join methods. This ties into the String.concat method. LANG-396" src/
          Sending src/main/java/org/apache/commons/lang3/StringUtils.java
          Sending src/test/java/org/apache/commons/lang3/StringUtilsTest.java
          Transmitting file data ..
          Committed revision 926448.

          Show
          Henri Yandell added a comment - svn ci -m "Adding concat(Object...) and concatWith(String, Object...) methods to provide vararg'd versions of the more prominent join methods. This ties into the String.concat method. LANG-396 " src/ Sending src/main/java/org/apache/commons/lang3/StringUtils.java Sending src/test/java/org/apache/commons/lang3/StringUtilsTest.java Transmitting file data .. Committed revision 926448.
          Hide
          Henri Yandell added a comment -

          Resolving the issue.

          LANG-611 has been created to look at the various improvements in the patch.

          Show
          Henri Yandell added a comment - Resolving the issue. LANG-611 has been created to look at the various improvements in the patch.

            People

            • Assignee:
              Unassigned
              Reporter:
              Henri Yandell
            • Votes:
              1 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development