Uploaded image for project: 'Commons Collections'
  1. Commons Collections
  2. COLLECTIONS-256

ListUtils.transformedList(list, transformer) doesn't transform

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Duplicate
    • Affects Version/s: 3.2
    • Fix Version/s: 4.0-alpha1, 4.0
    • Component/s: List
    • Labels:
      None
    • Environment:

      Java 1.5

      Description

      The static method ListUtils.transformedList(List list, Transformer trans) does not apply the transformer before returning the list. I've traced into the code and it falls all the way through to the TransformedCollection constructor which has documentation that states that items existing in the list are NOT transformed. This yields bizarre unexpected behavior for this method.

      Conversely, the ListUtils.predicatedList(List list, Predicate pred) DOES apply the predicate. These methods are very similar but behave inconsistently.

      If the transformer is not applied to the list, the method's usefulness is somewhat limited and causes the user to create an extra unwanted list in some circumstances:

      // To transform an existing list
      List myList = ... some list to be transformed ...
      List transformed = ListUtils.transformedList(new ArrayList(), myTransformer);
      transformed.addAll(myList);

      I would expect a much shorter implementation such as:

      List transformed = ListUtils.transformedList(myList, myTransformer)

        Attachments

        Issue Links

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              cardsharp Kurtis Williams

              Dates

              • Created:
                Updated:
                Resolved:

                Issue deployment