if (superTypeDeclaration != null && superTypeDeclaration.getTypeClassDef() != null ) {
ClassDefinition classDef = superTypeDeclaration.getTypeClassDef();
// inherit fields
for (org.kie.api.definition.type.FactField fld : classDef.getFields()) {
TypeFieldDescr inheritedFlDescr = buildInheritedFieldDescrFromDefinition(fld, typeDescr);
fieldMap.put(inheritedFlDescr.getFieldName(),
inheritedFlDescr);
}
// new classes are already distinguished from tagged external classes
isSuperClassTagged = !superTypeDeclaration.isNovel();
}
/*
else {
for ( TypeDefinition def : unresolvedTypes ) {
if ( def.getTypeClassName().equals( fullSuper ) ) {
TypeDeclarationDescr td = (TypeDeclarationDescr) def.typeDescr;
for ( TypeFieldDescr tf : td.getFields().values() ) {
fieldMap.put( tf.getFieldName(), tf.cloneAsInherited() );
}
isSuperClassDeclared = def.type.isNovel();
break;
}
isSuperClassDeclared = false;
}
}
*/
} else {
isSuperClassDeclared = false;
}
// look for the class externally
if ( !isSuperClassDeclared || isSuperClassTagged ) {
try {
Class superKlass;
if ( registry != null ) {
superKlass = registry.getTypeResolver().resolveType(fullSuper);
} else {
// if the supertype has not been declared, and we have got so far, it means that this class is not novel
superKlass = resolver.resolveType( fullSuper );
}
ClassFieldInspector inspector = new ClassFieldInspector(superKlass);
for (String name : inspector.getGetterMethods().keySet()) {
// classFieldAccessor requires both getter and setter
if (inspector.getSetterMethods().containsKey(name)) {
if (!inspector.isNonGetter(name) && !"class".equals(name)) {
TypeFieldDescr inheritedFlDescr = new TypeFieldDescr(
name,
new PatternDescr(
inspector.getFieldTypes().get(name).getName()));
inheritedFlDescr.setInherited(!Modifier.isAbstract(inspector.getGetterMethods().get(name).getModifiers()));
if (!fieldMap.containsKey(inheritedFlDescr.getFieldName()))
fieldMap.put(inheritedFlDescr.getFieldName(),
inheritedFlDescr);
}
}
}