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
,RuleConditionElement
,RuleComponent
public class GroupElement extends ConditionalElement implements Externalizable
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
GroupElement.Type
A public enum for CE types
-
Field Summary
Fields Modifier and Type Field Description static GroupElement.Type
AND
static GroupElement.Type
EXISTS
static GroupElement.Type
NOT
static GroupElement.Type
OR
-
Constructor Summary
Constructors Constructor Description GroupElement()
GroupElement(GroupElement.Type type)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addChild(int index, RuleConditionElement rce)
Adds the given child as the (index)th child of the this GroupElementGroupElement
addChild(RuleConditionElement child)
Adds a child to the current GroupElement.GroupElement
clone()
Clones all Conditional Elements but references the non ConditionalElement childrenprotected GroupElement
clone(boolean deepClone)
GroupElement
cloneOnlyGroup()
boolean
containesNode(GroupElement.Type node)
boolean
equals(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.Type
getType()
int
hashCode()
boolean
isAnd()
boolean
isExists()
boolean
isNot()
boolean
isOr()
boolean
isPatternScopeDelimiter()
Returns true in case this RuleConditionElement delimits a pattern visibility scope.boolean
isRoot()
protected void
mergeGroupElements(GroupElement parent, GroupElement child)
void
pack()
Optimize the group element subtree by removing redundancies like an AND inside another AND, OR inside OR, single branches AND/OR, etc.void
pack(GroupElement parent)
void
readExternal(ObjectInput in)
Declaration
resolveDeclaration(String identifier)
Resolves the given identifier in the current scope and returns the Declaration object for the declaration.void
setRoot(boolean root)
void
setType(GroupElement.Type type)
String
toString()
void
writeExternal(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:
readExternal
in interfaceExternalizable
- Throws:
IOException
ClassNotFoundException
-
writeExternal
public void writeExternal(ObjectOutput out) throws IOException
- Specified by:
writeExternal
in 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:RuleConditionElement
Returns a Map of declarations that are visible inside this conditional element- Specified by:
getInnerDeclarations
in interfaceRuleConditionElement
- Returns:
-
getInnerDeclarations
public Map<String,Declaration> getInnerDeclarations(String consequenceName)
-
getOuterDeclarations
public Map<String,Declaration> getOuterDeclarations()
Description copied from interface:RuleConditionElement
Returns a Map of declarations that are visible outside this conditional element.- Specified by:
getOuterDeclarations
in interfaceRuleConditionElement
- Returns:
-
getOuterDeclarations
public Map<String,Declaration> getOuterDeclarations(String consequenceName)
-
resolveDeclaration
public Declaration resolveDeclaration(String identifier)
Description copied from interface:RuleConditionElement
Resolves 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:
resolveDeclaration
in 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:
clone
in interfaceRuleConditionElement
- Specified by:
clone
in 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:RuleConditionElement
Returs a list of RuleConditionElement's that are nested inside the current element- Specified by:
getNestedElements
in interfaceRuleConditionElement
- Returns:
-
isPatternScopeDelimiter
public boolean isPatternScopeDelimiter()
Description copied from interface:RuleConditionElement
Returns 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:
isPatternScopeDelimiter
in interfaceRuleConditionElement
- Returns:
-
isRoot
public boolean isRoot()
-
setRoot
public void setRoot(boolean root)
-
containesNode
public boolean containesNode(GroupElement.Type node)
-
-