use of org.infinispan.protostream.descriptors.FileDescriptor in project kogito-runtimes by kiegroup.
the class ProtostreamProtobufAdapterTypeProvider method buildMessageTypes.
private FileDescriptorProto buildMessageTypes(FileDescriptor descriptor) {
FileDescriptorProto.Builder protoFileBuilder = FileDescriptorProto.newBuilder();
protoFileBuilder.setPackage(descriptor.getPackage());
protoFileBuilder.setName(descriptor.getName());
for (Descriptor message : descriptor.getMessageTypes()) {
protoFileBuilder.addMessageType(buildMessage(message));
}
return protoFileBuilder.build();
}
use of org.infinispan.protostream.descriptors.FileDescriptor in project kogito-runtimes by kiegroup.
the class ProtostreamProtobufAdapterTypeProviderTest method testFileDescriptorSortWithKogitoLastInOrigList.
@Test
void testFileDescriptorSortWithKogitoLastInOrigList() {
ProtostreamProtobufAdapterTypeProvider prov = new ProtostreamProtobufAdapterTypeProvider();
FileDescriptor fd1 = new FileDescriptor.Builder().withPackageName("kogito").build();
FileDescriptor fd2 = new FileDescriptor.Builder().withPackageName("org.kie.kogito.app").build();
List<FileDescriptor> fdCollectionKogitoOrder2 = Arrays.asList(fd2, fd1);
List<FileDescriptor> fdCollectionSorted2 = prov.sortFds(fdCollectionKogitoOrder2);
Assertions.assertThat(fdCollectionSorted2).hasSameElementsAs(fdCollectionKogitoOrder2);
Assertions.assertThat(fdCollectionSorted2.get(0)).isEqualTo(fd1);
}
use of org.infinispan.protostream.descriptors.FileDescriptor in project kogito-runtimes by kiegroup.
the class AbstractMarshallerGenerator method javaTypeForMessage.
protected String javaTypeForMessage(FileDescriptor d, String messageName, SerializationContext serializationContext) {
Map<String, FileDescriptor> descriptors = serializationContext.getFileDescriptors();
for (Entry<String, FileDescriptor> entry : descriptors.entrySet()) {
List<Descriptor> messages = entry.getValue().getMessageTypes();
for (Descriptor msg : messages) {
if (messageName.equals(msg.getName())) {
return packageFromOption(d, msg) + "." + messageName;
} else if (messageName.equals(msg.getFullName())) {
return packageFromOption(d, msg) + "." + msg.getName();
}
}
List<EnumDescriptor> enums = entry.getValue().getEnumTypes();
for (EnumDescriptor msg : enums) {
if (messageName.equals(msg.getName())) {
return packageFromOption(d, msg) + "." + messageName;
} else if (messageName.equals(msg.getFullName())) {
return packageFromOption(d, msg) + "." + msg.getName();
}
}
}
return null;
}
Aggregations