Dewfy
Dewfy

Reputation: 23644

spring SPeL combine filter and projection operations

Colleagues, how to combine together projection operator ![expr]and filter ?[ boolean ]. For example I have some entity:

class User {
    int age;
    String name;
}

I would like select from list of Users only name of user who is elder than 30.

Standalone projection looks like:

#myArray.![name]

Standalone filtering looks like:

#myArray.?[age > 30]

So how to put it together? Thank you in advance!

Upvotes: 1

Views: 2987

Answers (1)

Gary Russell
Gary Russell

Reputation: 174719

(#myArray.?[age > 30]).![name]

i.e. perform the projection on the results of the selection.

Upvotes: 5

Related Questions