Java Reference
In-Depth Information
Collection operations
The second aspect of the collection support in EL 3.0 concerns collection operations.
For this aspect, the specification only defines the syntax and behavior of a standard
set of collection operations to be implemented with ELResolvers . It has the ad-
vantage of allowing developers to modify the default behavior by providing their own
ELResolvers .
Execution of a collection operation is done through a stream pipeline which is made
up of:
• A stream object that represents the source of a pipeline; it is obtained from
the stream() method of the collection or array. In the case of a map, the
collection view of the map can be use as the source.
• Zero or more intermediate stream methods that return a stream object.
• A terminal operation, which is a stream method that returns nothing.
The following code demonstrates the construction of a pipeline by giving an example
of collection operations:
public class ELTestMain {
static ELProcessor el = new ELProcessor();
public static void main(String[] args) {
List l = new ArrayList();
l.add(1); l.add(8); l.add(7);
l.add(14); l.add(2);
el.defineBean("list", l);
out.println("Evaluation of " + l + " is
: " + el.eval("list"));
out.println("The ordering of: " + l + "
is : "
+
el.eval("list.stream().sorted().toList()"));
out.println("List of number < 7 : "
+
el.eval("list.stream().filter(s->s <
Search WWH ::




Custom Search