private void createCRUDRepository(JavaClassSource entitySource, Project project) { // build interface declaration final String name = entitySource.getName(); final String idFieldType = entitySource.getFields().stream() .filter(field -> field.hasAnnotation(Id.class)) .findFirst() .orElseThrow(IllegalArgumentException::new) .getType() .getSimpleName(); final String repoInterfaceDeclaration = "public interface " + name + "Repository extends CrudRepository<" + name + "," + idFieldType + "> {}"; JavaInterfaceSource repoSource = Roaster.parse(JavaInterfaceSource.class, repoInterfaceDeclaration) .setPackage(entitySource.getPackage()); repoSource.addImport("org.springframework.data.repository.CrudRepository"); Roaster.format(repoSource.toString()); // Create Java Classes Greeting and GreetingProperties JavaSourceFacet facet = project.getFacet(JavaSourceFacet.class); facet.saveJavaSource(repoSource); }
exampleClassNames.add(parameterSource.getType().getSimpleName());