Java Reference
In-Depth Information
reject() operations. The select() operation is analogous to the OCL
select() operation and specifies a subset of a collection as follows:
collection.select( v | boolean-expression-with-v )
Select returns a sublist of the specified collection. The list contains all ele-
ments for which the evaluation of boolean-expression-with-v results in
true . For example:
{1,2,3,4}.select(i | i >= 3) // returns {3,4}
typeSelect
A special version of a select expression is the typeSelect() expression. The
metaclass name is provided as the argument.
collection.typeSelect( classname )
typeSelect() returns a sublist of the specified collection that contains only
objects that are an instance of the specified class. For example:
elements.typeSelect(mindmap::Topic)
reject
The reject operation is similar to the select operation, but with reject we get the
subset of all the elements of the collection for which the expression evaluates to
false . The reject syntax is identical to the select syntax:
collection.reject( v | boolean-expression-with-v )
For example:
{1,2,3,4}.reject(i | i >= 3)
// returns {1,2}
collect
As shown in the previous section, the select() and reject() operations
always result in a subcollection of the original collection. Sometimes we want to
specify a collection that is derived from another collection but that contains
Search WWH ::




Custom Search