Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IPROTO-307 @Proto annotation #241

Merged
merged 1 commit into from Mar 11, 2024

Conversation

tristantarrant
Copy link
Member

@tristantarrant tristantarrant commented Mar 8, 2024

https://issues.redhat.com/browse/IPROTO-307
https://issues.redhat.com/browse/IPROTO-306

Adds a @Proto annotation for simple handling of protobuf entities. Also adds support for Java records

@tristantarrant tristantarrant added this to the 5.0.0.Final milestone Mar 8, 2024
@tristantarrant tristantarrant changed the title IPROTO-307 @ProtoSimple annotation IPROTO-307 @Proto annotation Mar 11, 2024
/**
* Defines a Protocol Buffers message without having to annotate all fields with {@link ProtoField}.
* Use this annotation to quickly generate messages from records or classes with public fields.
* Fields must be public and they will be assigned incremental numbers based on the declaration order.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should detail here that it's possible to overwrite fields with subsequent @protofield definitions.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

generatedSchema.registerSchema(ctx);
generatedSchema.registerMarshallers(ctx);

assertTrue(generatedSchema.getProtoFile().contains("message BareMessage"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also assert the generated fields contain the correct types?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

protobufType = Type.BYTES;
}
if (!javaType.isArray() && !javaType.isPrimitive() && javaType.isAbstract() && !javaType.isEnum()) {
throw new ProtoSchemaBuilderException("The type " + javaType.getCanonicalName() + " of field '" + fieldName + "' of " + clazz.getCanonicalName() + " should not be abstract, while processing " + this.protoSchemaGenerator.generator);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We throw the same exception in two places. We should either split the duplicated code into a method, or at least create the exception via the Log.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've promoted a few logs to Log, including this one.

@karesti
Copy link

karesti commented Mar 11, 2024

This is making my day

* IPROTO-306 Record support
@karesti karesti merged commit 19c364f into infinispan:main Mar 11, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants