all (type) in (list)

The all <type> construct introduces a collection of objects of a given type.

Purpose

You use this construct to filter a collection of objects of a specific type.

Syntax

all <type> [in <list>] [,where <test>[,]]

Description

You use this construct to collect all object instances in a collection.

The in construct is used to retrieve data from a collection of objects related to an existing object. The <list> parameter of the in construct must be an expression that denotes a collection.

You can add a where clause to test one or more conditions on an object. When you use the where clause with collections of objects, the comma before the where is required, whereas the comma at the end of the condition is optional.

Example

The following rule checks whether the total amount of all the coupons is at least 150. If this condition is true, a message is displayed to grant the customer a 10% discount on the next trip.

if
    the total amount of all coupons in the coupons of customer is at least 150 
then
    print "10% discount on the next trip";

The following rule checks whether the average price of all the tickets of this trip is between 100 and 200.

if
    the average price of all tickets in the tickets of trip is between 100 and 200
then
    print "The average price of all the tickets of this trip is between 100 and 200";

The following rule checks whether the number of purchases is more than 100. If this condition is true, a message is displayed. Notice that when the number of operator is applied to a collection that is defined by the all construct, the article all is removed to improve readability.

if 
    the number of purchases is more than 100
then 
    print "send 25% discount voucher";