if ( pkg == null ) return new ArrayList<FactMetaModel>();
List<TypeDeclarationDescr> types = pkg.getTypeDeclarations();
List<FactMetaModel> list = new ArrayList<FactMetaModel>( types.size() );
for ( TypeDeclarationDescr td : types ) {
FactMetaModel mm = new FactMetaModel();
mm.setName( td.getTypeName() );
mm.setSuperType( td.getSuperTypeName() );
Map<String, TypeFieldDescr> fields = td.getFields();
for ( Map.Entry<String, TypeFieldDescr> en : fields.entrySet() ) {
String fieldName = en.getKey();
TypeFieldDescr descr = en.getValue();
FieldMetaModel fm = new FieldMetaModel( fieldName,
descr.getPattern().getObjectType() );
mm.getFields().add( fm );
}
Map<String, AnnotationDescr> annotations = td.getAnnotations();
for ( Map.Entry<String, AnnotationDescr> en : annotations.entrySet() ) {
String annotationName = en.getKey();
AnnotationDescr descr = en.getValue();
Map<String, String> values = descr.getValues();
AnnotationMetaModel am = new AnnotationMetaModel( annotationName,
values );
mm.getAnnotations().add( am );
}
list.add( mm );
}
return list;