public static Set<String> getPrimitiveTypes(Collection<HollowSchema> schemaList) { Set<String> primitiveTypes = new HashSet<>(); for (HollowSchema schema : schemaList) { String type = schema.getName(); if (!isPrimitiveType(type)) continue; primitiveTypes.add(type); } return primitiveTypes; }
private static String computeSubPackageName(HollowObjectSchema schema) { String type = schema.getName(); if (isPrimitiveType(type)) { return "core"; } return SUB_PACKAGE_NAME; }
/** * Adds the schema name to the set if the schema name doesn't correspond to a Hollow * primitive type. Factored out to prevent bloat in the switch statement it is called * from. */ private void addToSetIfNotPrimitiveOrCollection(Set<String> schemaNameSet, String... schemaNames) { for (String schemaName : schemaNames) { // collections schemas get brought in by a star import if (!HollowCodeGenerationUtils.isCollectionType(schemaName, dataset) && !HollowCodeGenerationUtils.isPrimitiveType(schemaName)) { schemaNameSet.add(schemaName); } } } }
public void generateFiles(File directory) throws IOException { Path destinationPath = directory.toPath(); Path packagePath = Paths.get(packageName.replace(".", File.separator)); if (!destinationPath.toAbsolutePath().endsWith(packagePath)) { destinationPath = destinationPath.resolve(packagePath); } directory = destinationPath.toFile(); if (!directory.exists()) directory.mkdirs(); for (HollowSchema schema : dataset.getSchemas()) { if (schema instanceof HollowObjectSchema && !isPrimitiveType(schema.getName())) { HollowPOJOClassGenerator generator = new HollowPOJOClassGenerator(dataset, (HollowObjectSchema) schema, packageName, pojoClassNameSuffix); FileWriter writer = new FileWriter(new File(directory, generator.getClassName() + ".java")); writer.write(generator.generate()); writer.close(); } } } }
for(HollowSchema schema : dataset.getSchemas()) { String type = schema.getName(); if (config.isUseHollowPrimitiveTypes() && HollowCodeGenerationUtils.isPrimitiveType(type)) continue; // skip if using hollow primitive type