Filter and Projection on Collections using OGNL
Filter and Projection on Collections using OGNL
Filter
Syntax for the filter
collectionObjectName.{? expression}
Filtering filter the objects from the collection based on the expression provided.
For example
students.{?#this.percentage>70}
Here it will return new students collection having percentage greater than 70.
Filtering always gives less than or equal to the number of elements available in the collection based on the provided expression.
Projection
Syntax for projection
Projecting always gives exactly the same number elements available in the original main collection.
students.{name};
Here this projection will gives you a new collection contains only the name of all the students elements available in the original collection.
students.{name+''+percentage};
Here this projection will gives you a new collection contains the name + percentage combination of all the students elements available in the original collection.
students.{?#this.percentage > 50}.{username}
Here this projection will give you a new collection contains the name of all the students having percentage greater than 50.
Filter
Syntax for the filter
collectionObjectName.{? expression}
Filtering filter the objects from the collection based on the expression provided.
For example
students.{?#this.percentage>70}
Here it will return new students collection having percentage greater than 70.
Filtering always gives less than or equal to the number of elements available in the collection based on the provided expression.
Projection
Syntax for projection
Projecting always gives exactly the same number elements available in the original main collection.
students.{name};
Here this projection will gives you a new collection contains only the name of all the students elements available in the original collection.
students.{name+''+percentage};
Here this projection will gives you a new collection contains the name + percentage combination of all the students elements available in the original collection.
students.{?#this.percentage > 50}.{username}
Here this projection will give you a new collection contains the name of all the students having percentage greater than 50.