(Deprecated) logical (in insert)
The logical keyword declares the type
of the object to be inserted into the working memory.
Purpose
The Truth Maintenance System (TMS), the logical (in insert) IRL
keyword and the insertLogical (object) method are deprecated as of V8.6.0.0. These
features will be removed in a future release. See Deprecated and removed features for migration details.
This
keyword is used within an insert statement to indicate
that the object to be inserted in the working memory is of the logical
type.
Context
Rule conditions, rule actions, or functions
Syntax
insert logical object
[{statement1 ... statementn}] ;
Description
The insert statement
creates a new object of a given class, execute statements on the scope
of the object, and inserts the object into the working memory. The logical keyword
indicates that the object is of a logical type. A logical object has
two properties: the object is unique and the validity of the object
is maintained.
To specify the uniqueness of the object, you must redefine the Java™ Object.equals method in your Java class (see the example below). The process goes on as follows:
An object is created normally from the specified constructor.
This object is then tested by the equals method to determine whether an object that equals this object already exists in the working memory.
If an existing object in the working memory equals the object, the new object is not inserted into the working memory. The existing object is set to have a new justification that corresponds to the condition part of the rule that has just been executed.
If no existing object in the working memory equals the object, the new object is inserted into the working memory. This object is then maintained by the condition part of the rule that inserted it.
Maintenance of a logical object means that as long as the
condition part of a rule that justified the object remains true,
the object is kept in the working memory. If the condition part becomes false,
the object loses a justification. A logical object that loses its
last justification is automatically retracted from the working memory.
To
benefit of the Truth Maintenance System, you must redefine the Java Object.equals method
and define a hashCode method in your Java class, as follows:
public boolean equals (Object obj)
{
if (obj == null || !(obj instanceof className))
return(false);
className myObj = (className)obj;
return (fieldName.equals(myObj.fieldName));
}
...public int hashCode()
{
return (fieldName.hashCode());
}If more than one field discriminates the
object, the equals and hashCode methods
must apply to each field.