@Test void testAnswerWithVariableInfoProtoFile() { Proto proto = generator.generate("@Indexed", "@Field(store = Store.YES)", "org.kie.kogito.test.persons", Answer.class); assertThat(proto).isNotNull(); assertThat(proto.getPackageName()).isEqualTo("org.kie.kogito.test.persons"); assertThat(proto.getSyntax()).isEqualTo("proto2"); assertThat(proto.getEnums()).hasSize(1); ProtoEnum answer = proto.getEnums().get(0); assertThat(answer).isNotNull(); assertThat(answer.getName()).isEqualTo("Answer"); assertThat(answer.getComment()).isBlank(); assertThat(answer.getJavaPackageOption()).isEqualTo("org.kie.kogito.codegen.data"); assertThat(answer.getFields()).hasSize(3); Map<String, Integer> fields = answer.getFields(); assertThat(fields).isNotNull() .containsEntry("YES", 0) .containsEntry("MAYBE", 1) .containsEntry("NO", 2); }
public Proto generate(String packageName, Collection<Class<?>> dataModel, String... headers) { try { Proto proto = new Proto(packageName, headers); for (Class<?> clazz : dataModel) { if (clazz.isEnum()) { enumFromClass(proto, clazz, null); } else { messageFromClass(proto, clazz, null, null, null); } } return proto; } catch (Exception e) { throw new RuntimeException("Error while generating proto for data model", e); } }
ReflectionProtoGenerator extends AbstractProtoGenerator<Class<?>> { public Proto generate(String packageName, Collection<Class<?>> dataModel, String... headers) { try { Proto proto = new Proto(packageName, headers); for (Class<?> clazz : dataModel) { if (clazz.isEnum()) { enumFromClass(proto, clazz, null); } else { messageFromClass(proto, clazz, null, null, null); } } return proto; } catch (Exception e) { throw new RuntimeException("Error while generating proto for data model", e); } } }
ReflectionProtoGenerator extends AbstractProtoGenerator<Class<?>> { public Proto generate(String packageName, Collection<Class<?>> dataModel, String... headers) { try { Proto proto = new Proto(packageName, headers); for (Class<?> clazz : dataModel) { if (clazz.isEnum()) { enumFromClass(proto, clazz, null); } else { messageFromClass(proto, clazz, null, null, null); } } return proto; } catch (Exception e) { throw new RuntimeException("Error while generating proto for data model", e); } }  }
ReflectionProtoGenerator extends AbstractProtoGenerator<Class<?>> { public Proto generate(String packageName, Collection<Class<?>> dataModel, String... headers) { try { Proto proto = new Proto(packageName, headers); for (Class<?> clazz : dataModel) { if (clazz.isEnum()) { enumFromClass(proto, clazz, null); } else { messageFromClass(proto, clazz, null, null, null); } } return proto; } catch (Exception e) { throw new RuntimeException("Error while generating proto for data model", e); } }  Proto generate(String packageName, Collection<Class<?>> dataModel, String... headers); @Override Proto generate(String messageComment, String fieldComment, String packageName, Class<?> dataModel, String... headers); Collection<Class<?>> extractDataClasses(Collection<Class<?>> input, String targetDirectory); }
ReflectionProtoGenerator extends AbstractProtoGenerator<Class<?>> { public Proto generate(String packageName, Collection<Class<?>> dataModel, String... headers) { try { Proto proto = new Proto(packageName, headers); for (Class<?> clazz : dataModel) { if (clazz.isEnum()) { enumFromClass(proto, clazz, null); } else { messageFromClass(proto, clazz, null, null, null); } } return proto; } catch (Exception e) { throw new RuntimeException("Error while generating proto for data model", e); } }  Proto generate(String packageName, Collection<Class<?>> dataModel, String... headers); @Override Proto generate(String messageComment, String fieldComment, String packageName, Class<?> dataModel, String... headers); Collection<Class<?>> extractDataClasses(Collection<Class<?>> input, String targetDirectory);  }