存在テストを行う条件

特定タイプの 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 つのビジネス用語が 1 回以上は出現しているかをチェックします。 データにそのビジネス用語が複数回出現する場合もあります。

次の条件は、1 つ以上の customer オブジェクトを検索します。

if 
	there is at least one customer 
then... 

次の例では、senior Gold customer の数が 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...