Package org.drools.compiler.builder.impl
Class ClassHierarchyManager
- java.lang.Object
-
- org.drools.compiler.builder.impl.ClassHierarchyManager
-
public class ClassHierarchyManager extends Object
-
-
Field Summary
Fields Modifier and Type Field Description protected KnowledgeBuilderImpl
kbuilder
protected List<AbstractClassTypeDeclarationDescr>
sortedDescriptors
protected Map<QualifiedName,Collection<QualifiedName>>
taxonomy
-
Constructor Summary
Constructors Constructor Description ClassHierarchyManager(Collection<AbstractClassTypeDeclarationDescr> unsortedDescrs, KnowledgeBuilderImpl kbuilder)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addDeclarationToPackagePreservingOrder(org.drools.core.rule.TypeDeclaration type, AbstractClassTypeDeclarationDescr typeDescr, org.drools.core.definitions.InternalKnowledgePackage tgtPackage, Map<String,PackageRegistry> pkgRegistryMap)
protected TypeFieldDescr
buildInheritedFieldDescrFromDefinition(org.kie.api.definition.type.FactField fld, TypeDeclarationDescr typeDescr)
List<AbstractClassTypeDeclarationDescr>
getSortedDescriptors()
protected static boolean
hasCircularDependency(QualifiedName name, QualifiedName typeName, Map<QualifiedName,Collection<QualifiedName>> taxonomy)
void
inheritFields(PackageRegistry pkgRegistry, AbstractClassTypeDeclarationDescr typeDescr, Collection<AbstractClassTypeDeclarationDescr> sortedTypeDescriptors, List<org.drools.compiler.builder.impl.TypeDefinition> unresolvedTypes, Map<String,AbstractClassTypeDeclarationDescr> unprocessableDescrs)
protected void
mergeFields(String simpleSuperTypeName, String superTypePackageName, String fullSuper, TypeDeclarationDescr typeDescr, List<org.drools.compiler.builder.impl.TypeDefinition> unresolvedTypes, Map<String,AbstractClassTypeDeclarationDescr> unprocessableDescrs, org.drools.core.addon.TypeResolver resolver)
protected void
mergeInheritedFields(TypeDeclarationDescr typeDescr, List<org.drools.compiler.builder.impl.TypeDefinition> unresolvedTypes, Map<String,AbstractClassTypeDeclarationDescr> unprocessableDescrs, org.drools.core.addon.TypeResolver typeResolver)
In order to build a declared class, the fields inherited from its superclass(es) are added to its declaration.protected List<AbstractClassTypeDeclarationDescr>
sortByHierarchy(Collection<AbstractClassTypeDeclarationDescr> unsortedDescrs, KnowledgeBuilderImpl kbuilder)
Utility method to sort declared beans.
-
-
-
Field Detail
-
kbuilder
protected KnowledgeBuilderImpl kbuilder
-
sortedDescriptors
protected List<AbstractClassTypeDeclarationDescr> sortedDescriptors
-
taxonomy
protected Map<QualifiedName,Collection<QualifiedName>> taxonomy
-
-
Constructor Detail
-
ClassHierarchyManager
public ClassHierarchyManager(Collection<AbstractClassTypeDeclarationDescr> unsortedDescrs, KnowledgeBuilderImpl kbuilder)
-
-
Method Detail
-
getSortedDescriptors
public List<AbstractClassTypeDeclarationDescr> getSortedDescriptors()
-
sortByHierarchy
protected List<AbstractClassTypeDeclarationDescr> sortByHierarchy(Collection<AbstractClassTypeDeclarationDescr> unsortedDescrs, KnowledgeBuilderImpl kbuilder)
Utility method to sort declared beans. Linearizes the hierarchy, i.e.generates a sequence of declaration such that, if Sub is subclass of Sup, then the index of Sub will be > than the index of Sup in the resulting collection. This ensures that superclasses are processed before their subclasses
-
hasCircularDependency
protected static boolean hasCircularDependency(QualifiedName name, QualifiedName typeName, Map<QualifiedName,Collection<QualifiedName>> taxonomy)
-
inheritFields
public void inheritFields(PackageRegistry pkgRegistry, AbstractClassTypeDeclarationDescr typeDescr, Collection<AbstractClassTypeDeclarationDescr> sortedTypeDescriptors, List<org.drools.compiler.builder.impl.TypeDefinition> unresolvedTypes, Map<String,AbstractClassTypeDeclarationDescr> unprocessableDescrs)
-
mergeInheritedFields
protected void mergeInheritedFields(TypeDeclarationDescr typeDescr, List<org.drools.compiler.builder.impl.TypeDefinition> unresolvedTypes, Map<String,AbstractClassTypeDeclarationDescr> unprocessableDescrs, org.drools.core.addon.TypeResolver typeResolver)
In order to build a declared class, the fields inherited from its superclass(es) are added to its declaration. Inherited descriptors are marked as such to distinguish them from native ones. Various scenarioes are possible. (i) The superclass has been declared in the DRL as well : the fields are cloned as inherited (ii) The superclass is imported (external), but some of its fields have been tagged with metadata (iii) The superclass is imported.The search for field descriptors is carried out in the order. (i) and (ii+iii) are mutually exclusive. The search is as such: (i) The superclass' declared fields are used to build the base class additional fields (iii) The superclass is inspected to discover its (public) fields, from which descriptors are generated (ii) Both (i) and (iii) are applied, but the declared fields override the inspected ones
- Parameters:
typeDescr
- The base class descriptor, to be completed with the inherited fields descriptors
-
mergeFields
protected void mergeFields(String simpleSuperTypeName, String superTypePackageName, String fullSuper, TypeDeclarationDescr typeDescr, List<org.drools.compiler.builder.impl.TypeDefinition> unresolvedTypes, Map<String,AbstractClassTypeDeclarationDescr> unprocessableDescrs, org.drools.core.addon.TypeResolver resolver)
-
buildInheritedFieldDescrFromDefinition
protected TypeFieldDescr buildInheritedFieldDescrFromDefinition(org.kie.api.definition.type.FactField fld, TypeDeclarationDescr typeDescr)
-
addDeclarationToPackagePreservingOrder
public void addDeclarationToPackagePreservingOrder(org.drools.core.rule.TypeDeclaration type, AbstractClassTypeDeclarationDescr typeDescr, org.drools.core.definitions.InternalKnowledgePackage tgtPackage, Map<String,PackageRegistry> pkgRegistryMap)
-
-