History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: GROOVY-2445
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Paul King
Reporter: Mike Dillon
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
groovy

Provide an enhanced each() method for subclasses of java.lang.Enum

Created: 25/Dec/07 01:17 PM   Updated: 08/Feb/08 01:26 AM
Component/s: groovy-jdk
Affects Version/s: 1.5, 1.5.1
Fix Version/s: 1.5.2

Time Tracking:
Not Specified

File Attachments: 1. Text File Enum-each.patch (4 kb)


Testcase included: yes
Patch Submitted: Yes


 Description  « Hide
Currently the each() method for subclasses of java.lang.Enum is the default each() method that returns the enum class itself in a single-element list. I believe it would be useful for the each() method to iterate through the values of the enum.

The provided patch implements this functionality by providing enum-specific behavior in DefaultTypeTransformation.asCollection(). This makes each(), eachWithIndex(), for (... in ...), and perhaps other constructs use the enum values as the collection instead of the single element list containing the enum class itself.

The provided test case tests only each() and the for/in behavior. It also introduces a new groovy.vm5.GroovyMethodsTest class for DGM tests that should only be run under Java 5 and later.



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Paul King - 28/Dec/07 03:17 AM
Patch looks good to me.

Paul King - 28/Dec/07 05:10 AM
Added

Paul King - 08/Feb/08 01:26 AM
close off release 1.5.4