Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-9711

@Sortable annotation always sorts by the parent properties

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.0.5
    • Fix Version/s: 4.0.0-alpha-1, 3.0.6
    • Component/s: groovy-runtime
    • Labels:
      None
    • Environment:
      Windows 10 version 1809
      AdoptOpenJDK version 8.0.242.08
      Groovy 3.0.5

      Description

      Adding includeSuperProperties = false doesn't help either.
      If the @Sortable annotation is removed from the super-class the test passes.

      Example:

      import groovy.transform.Sortable
      import org.junit.Test
      
      class SortableTest {
      
       @Sortable(includes = ["num"])
       class SortableClass{
       Integer num
       }
      
       @Sortable(includeSuperProperties = false, includes = ["str"])
       class SortableChild extends SortableClass {
       String str
       }
      
       @Test
       void test(){
       List<SortableChild> unsortedList = [new SortableChild([str: "B", num: 1]), new SortableChild([str: "A", num: 2])]
       List<SortableChild> sortedList = unsortedList.toSorted()
       assert sortedList[0].str == "A" //Fails here
       }
      }

        Attachments

          Activity

            People

            • Assignee:
              paulk Paul King
              Reporter:
              TedL Ted Lundqvist
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 10m
                10m