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; } }
protected void intro(EntityType model, CodeWriter writer) throws IOException { String simpleName = model.getSimpleName(); Type queryType = typeMappings.getPathType(model, model, false); // package if (!queryType.getPackageName().isEmpty()) { writer.packageDecl(queryType.getPackageName()); } // imports writer.imports(NumberExpression.class.getPackage()); writer.imports(ConstructorExpression.class, Generated.class); // javadoc writer.javadoc(queryType + " is a Querydsl Projection type for " + simpleName); writer.line("@Generated(\"", getClass().getName(), "\")"); // class header // writer.suppressWarnings("serial"); Type superType = new ClassType(TypeCategory.SIMPLE, ConstructorExpression.class, model); writer.beginClass(queryType, superType); writer.privateStaticFinal(Types.LONG_P, "serialVersionUID", String.valueOf(model.hashCode())); }