|
|||||
|
|||||
Useful Things |
MVEL 2.0 Projections and Folds
Put simply, projections (also known as list comprehensions) are a way of representing collections. Using a very simple syntax, you can inspect very complex object models inside collections. Imagine you have a collection of User objects. Each of these objects has a Parent. Now say you want to get a list of all names of the parents (assuming the Parent class has a name field) in the hierarchy of users, you would write something like this: You can even perform nested operations. Imagine instead, that the User object had a collection member called familyMembers, and we wanted a list of all the family members names: FiltersYou can also filter projections with a constraint with the
Other ExamplesHere are some more examples: Here is a functional Quicksort algorithm implemented using projections: |
||||
|
Copyright 2003-2006 - The Codehaus. All rights reserved unless otherwise noted.
Powered by Atlassian Confluence
|
|||||