存在テストを行う条件

特定のタイプのビジネス用語がデータ・セット内に 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 つの customer オブジェクトがあるかどうか探します。

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...