Package org.drools.core.rule
Class GroupElement
- java.lang.Object
-
- org.drools.core.rule.ConditionalElement
-
- org.drools.core.rule.GroupElement
-
- All Implemented Interfaces:
Externalizable,Serializable,Cloneable,RuleComponent,RuleConditionElement
public class GroupElement extends ConditionalElement implements 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(Object object)List<RuleConditionElement>getChildren()Map<String,Declaration>getInnerDeclarations()Returns a Map of declarations that are visible inside this conditional elementMap<String,Declaration>getInnerDeclarations(String consequenceName)List<RuleConditionElement>getNestedElements()Returs a list of RuleConditionElement's that are nested inside the current elementMap<String,Declaration>getOuterDeclarations()Returns a Map of declarations that are visible outside this conditional element.Map<String,Declaration>getOuterDeclarations(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(ObjectInput in)DeclarationresolveDeclaration(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)StringtoString()voidwriteExternal(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(ObjectInput in) throws IOException, ClassNotFoundException
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-
writeExternal
public void writeExternal(ObjectOutput out) throws IOException
- Specified by:
writeExternalin interfaceExternalizable- Throws:
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 List<RuleConditionElement> getChildren()
-
getInnerDeclarations
public Map<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 Map<String,Declaration> getInnerDeclarations(String consequenceName)
-
getOuterDeclarations
public Map<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 Map<String,Declaration> getOuterDeclarations(String consequenceName)
-
resolveDeclaration
public Declaration resolveDeclaration(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)
-
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()
-
getNestedElements
public 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)
-
-