-
Notifications
You must be signed in to change notification settings - Fork 524
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
[Java] Using sinceVersion from field instead of type declaration #548
[Java] Using sinceVersion from field instead of type declaration #548
Conversation
I also added sinceVersion static methods for composite type members. |
<type name="version" primitiveType="uint16"/> | ||
<type name="headerLength" primitiveType="uint16"/> | ||
|
||
<type name="extraField" primitiveType="int32" sinceVersion="5"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The spec states "Message header encoding cannot change."
In general, this looks quite good. Thanks for adding the test! |
Should probably remove the extension to the MessageHeader, though. |
Extending a message header is tricky. The message header itself does not come with its own length fields thus it will break existing code which expects message headers to be constant length. It is a part of the specification I've never been comfortable with. The fact that the schemas cannot cross reference makes this more tricky and the only practical way to do anything cross schema is to relay on fixed message headers and other types like group and var data header encodings. |
Okay, I removed message header extension, but I still would like to have sinceVersion methods in composite decoder classes, if it is not a problem. |
1a03c40
to
c85b8fb
Compare
c85b8fb
to
9807e40
Compare
@zyulyaev The NULL_VAL and SBE_UNKNOWN make it easy to deal with an enum in a switch statement. Without them you could get a NullPointerException. |
@mjpt777 Sorry, I meant “return”, not “remove”. And that’s exactly my point. But now generated “if” block returns null reference, not the NULL_VAL for enums. |
@zyulyaev Yes it would make more sense to return the NULL_VAL from the property getter if not present. Good spot. |
@zyulyaev I've made a change to return the NULL_VAL like you suggested. |
@mjpt777 Great, thank you! |
Generated
if
statement in decoder's methods must usesinceVersion
from fields declaration, not type declarations.