存在テストを行う条件
1 データ・セットに特定のタイプのビジネス用語が 1 つ以上存在するかどうかを確認する条件を作成できます。
以下に示す定義は、指定されたデータの存在をテストする演算子を説明しています。
- there are
演算子の there are は、ルールを呼び出すアプリケーションから提供されるデータに一定タイプのビジネス用語が特定の数だけ存在するかをテストします。
以下の条件は、2 人の顧客の存在をチェックします。
if there are 2 customers then...
演算子 where を使用すると、ビジネス用語に適用される複数の条件を指定できます。
次のルール条件は、顧客の数が 10 人で、かつ各顧客がゴールド・カテゴリーのメンバーの場合のみ true になります。
if there are 10 customers where the category of each customer is Gold, then...
- there are at least と there are at most
次の演算子は、データに含まれるビジネス用語のインスタンスが指定された数より多いか少ないかをチェックします。
there are at least: ビジネス用語の出現箇所の数が指定された数以上である場合、この条件は真です。
there are at most: ビジネス用語の出現箇所の数が指定された数以下である場合、この条件は真です。
次の条件は、ゴールド顧客の数が 3 人以下であることをチェックします。
if there are at most 3 customers where the category of each customer is Gold, then...
次の条件は、シルバー顧客よりもゴールド顧客の方が多いかどうかをチェックします。 このルールは、まず始めに以下の変数を定義します。
silver customers: シルバー・カテゴリー内の顧客のリスト。
silver count: シルバー・カテゴリー内の顧客の数。
次に、このルールは、これらの変数を使用してゴールド顧客の数をシルバー顧客の数と比較します。
definitions set 'silver customers' to all customers where the category of each customer is Silver; set 'silver count' to the number of 'silver customers if there are at least (’silver count’ + 1) customers where the category of each customer is Gold, then...
- there is at least one
BAL 演算子の there is at least one は、ルールを呼び出すアプリケーションから提供されるデータにビジネス用語のインスタンスが 1 つ以上あることをチェックします。 データに、ビジネス用語のインスタンスが複数含まれていても構いません。
以下の条件は、customer オブジェクトが 1 つ以上あるかを調べます。
if there is at least one customer then...
次の例では、シニア・ゴールド顧客が 1 人以上いるかをチェックします。
definitions set ’gold customers’ to all customers where the category of each customer is Gold; if there is at least one customer in ’gold customers’ where the age of this customer is at least 65, then...