Package org.drools.base.rule
Class GroupElement
- java.lang.Object
-
- org.drools.base.rule.ConditionalElement
-
- org.drools.base.rule.GroupElement
-
- All Implemented Interfaces:
java.io.Externalizable,java.io.Serializable,java.lang.Cloneable,RuleComponent,RuleConditionElement
public class GroupElement extends ConditionalElement implements java.io.Externalizable
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classGroupElement.TypeA public enum for CE types
-
Field Summary
Fields Modifier and Type Field Description static GroupElement.TypeANDstatic GroupElement.TypeEXISTSstatic GroupElement.TypeNOTstatic GroupElement.TypeOR
-
Constructor Summary
Constructors Constructor Description GroupElement()GroupElement(GroupElement.Type type)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddChild(int index, RuleConditionElement rce)Adds the given child as the (index)th child of the this GroupElementGroupElementaddChild(RuleConditionElement child)Adds a child to the current GroupElement.GroupElementclone()Clones all Conditional Elements but references the non ConditionalElement childrenprotected GroupElementclone(boolean deepClone)GroupElementcloneOnlyGroup()booleancontainesNode(GroupElement.Type node)booleanequals(java.lang.Object object)java.util.List<RuleConditionElement>getChildren()java.util.Map<java.lang.String,Declaration>getInnerDeclarations()Returns a Map of declarations that are visible inside this conditional elementjava.util.Map<java.lang.String,Declaration>getInnerDeclarations(java.lang.String consequenceName)java.util.List<RuleConditionElement>getNestedElements()Returs a list of RuleConditionElement's that are nested inside the current elementjava.util.Map<java.lang.String,Declaration>getOuterDeclarations()Returns a Map of declarations that are visible outside this conditional element.java.util.Map<java.lang.String,Declaration>getOuterDeclarations(java.lang.String consequenceName)GroupElement.TypegetType()inthashCode()booleanisAnd()booleanisExists()booleanisNot()booleanisOr()booleanisPatternScopeDelimiter()Returns true in case this RuleConditionElement delimits a pattern visibility scope.booleanisRoot()protected voidmergeGroupElements(GroupElement parent, GroupElement child)voidpack()Optimize the group element subtree by removing redundancies like an AND inside another AND, OR inside OR, single branches AND/OR, etc.voidpack(GroupElement parent)voidreadExternal(java.io.ObjectInput in)DeclarationresolveDeclaration(java.lang.String identifier)Resolves the given identifier in the current scope and returns the Declaration object for the declaration.voidsetRoot(boolean root)voidsetType(GroupElement.Type type)java.lang.StringtoString()voidwriteExternal(java.io.ObjectOutput out)
-
-
-
Field Detail
-
AND
public static final GroupElement.Type AND
-
OR
public static final GroupElement.Type OR
-
NOT
public static final GroupElement.Type NOT
-
EXISTS
public static final GroupElement.Type EXISTS
-
-
Constructor Detail
-
GroupElement
public GroupElement()
-
GroupElement
public GroupElement(GroupElement.Type type)
-
-
Method Detail
-
readExternal
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException- Specified by:
readExternalin interfacejava.io.Externalizable- Throws:
java.io.IOExceptionjava.lang.ClassNotFoundException
-
writeExternal
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException- Specified by:
writeExternalin interfacejava.io.Externalizable- Throws:
java.io.IOException
-
addChild
public GroupElement addChild(RuleConditionElement child)
Adds a child to the current GroupElement. Restrictions are: NOT/EXISTS: can have only one child, either a single Pattern or another CE
-
addChild
public void addChild(int index, RuleConditionElement rce)Adds the given child as the (index)th child of the this GroupElement
-
getChildren
public java.util.List<RuleConditionElement> getChildren()
-
getInnerDeclarations
public java.util.Map<java.lang.String,Declaration> getInnerDeclarations()
Description copied from interface:RuleConditionElementReturns a Map of declarations that are visible inside this conditional element- Specified by:
getInnerDeclarationsin interfaceRuleConditionElement- Returns:
-
getInnerDeclarations
public java.util.Map<java.lang.String,Declaration> getInnerDeclarations(java.lang.String consequenceName)
-
getOuterDeclarations
public java.util.Map<java.lang.String,Declaration> getOuterDeclarations()
Description copied from interface:RuleConditionElementReturns a Map of declarations that are visible outside this conditional element.- Specified by:
getOuterDeclarationsin interfaceRuleConditionElement- Returns:
-
getOuterDeclarations
public java.util.Map<java.lang.String,Declaration> getOuterDeclarations(java.lang.String consequenceName)
-
resolveDeclaration
public Declaration resolveDeclaration(java.lang.String identifier)
Description copied from interface:RuleConditionElementResolves the given identifier in the current scope and returns the Declaration object for the declaration. Returns null if identifier can not be resolved.- Specified by:
resolveDeclarationin interfaceRuleConditionElement- Returns:
-
pack
public void pack()
Optimize the group element subtree by removing redundancies like an AND inside another AND, OR inside OR, single branches AND/OR, etc. LogicTransformer does further, more complicated, transformations
-
mergeGroupElements
protected void mergeGroupElements(GroupElement parent, GroupElement child)
-
pack
public void pack(GroupElement parent)
-
equals
public boolean equals(java.lang.Object object)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
clone
public GroupElement clone()
Clones all Conditional Elements but references the non ConditionalElement children- Specified by:
clonein interfaceRuleConditionElement- Specified by:
clonein classConditionalElement- Returns:
-
cloneOnlyGroup
public GroupElement cloneOnlyGroup()
-
clone
protected GroupElement clone(boolean deepClone)
-
getType
public GroupElement.Type getType()
-
setType
public void setType(GroupElement.Type type)
-
isAnd
public boolean isAnd()
-
isOr
public boolean isOr()
-
isNot
public boolean isNot()
-
isExists
public boolean isExists()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getNestedElements
public java.util.List<RuleConditionElement> getNestedElements()
Description copied from interface:RuleConditionElementReturs a list of RuleConditionElement's that are nested inside the current element- Specified by:
getNestedElementsin interfaceRuleConditionElement- Returns:
-
isPatternScopeDelimiter
public boolean isPatternScopeDelimiter()
Description copied from interface:RuleConditionElementReturns true in case this RuleConditionElement delimits a pattern visibility scope. For instance, AND CE is not a scope delimiter, while NOT CE is a scope delimiter- Specified by:
isPatternScopeDelimiterin interfaceRuleConditionElement- Returns:
-
isRoot
public boolean isRoot()
-
setRoot
public void setRoot(boolean root)
-
containesNode
public boolean containesNode(GroupElement.Type node)
-
-