private void serialize(Map<String, EntityType> types, Serializer serializer) throws IOException {
   for (EntityType entityType : types.values()) {
     if (serialized.add(entityType)) {
       Type type = typeMappings.getPathType(entityType, entityType, true);
       String packageName = type.getPackageName();
       String className =
           packageName.length() > 0
               ? (packageName + "." + type.getSimpleName())
               : type.getSimpleName();
       write(serializer, className.replace('.', '/') + ".java", entityType);
     }
   }
 }
 private EntityType createEntityType(Class<?> cl, Map<String, EntityType> types) {
   if (types.containsKey(cl.getName())) {
     return types.get(cl.getName());
   } else {
     EntityType type = new EntityType(new ClassType(TypeCategory.ENTITY, cl));
     typeMappings.register(type, queryTypeFactory.create(type));
     if (!cl.getSuperclass().equals(Object.class)) {
       type.addSupertype(new Supertype(new ClassType(cl.getSuperclass())));
     }
     types.put(cl.getName(), type);
     allTypes.put(cl.getName(), type);
     return type;
   }
 }