-
Notifications
You must be signed in to change notification settings - Fork 30
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
Custom default values for fields #48
Comments
Actually it does. However, fields are not initialized in constructor directly. There are 3 ways to create a message:
Please check full source of the generated class. It is similar to classes generated by google's If you are not sure - I recommend you to write a unit test to double-check that there is default value, something like https://github.com/protostuff/protostuff-compiler/blob/master/protostuff-it/src/test/java/io/protostuff/it/java/ScalarTest.java or https://github.com/protostuff/protostuff-compiler/blob/master/protostuff-it/src/test/java/io/protostuff/it/java/MessageTest.java. |
The default values are (zero values, -1 for enums, and empty strings), but these are not the ones that one would like to have.
And generated code for this message. There are no default values ("/logout" and "delete" for fields path and method respectively) for fields in the Builder's and Message's constructors. Can I create an object instance without having other initialized messages objects with default fields values from field's extensions default in the .proto file as from code that protoc generates? |
Sorry, I misinterpreted issue description. You are right, custom default values are not supported. I cannot say when I can implement support for custom default values, as currently I'm quite busy with https://github.com/protostuff/protobuf-jetbrains-plugin. If you are willing to help, I will gladly accept pull request. |
I have this message:
Compiler generates this code:
There are neither default initializers for fields someField, someOtherField for private constructor nor for SomeInnerMessage.Builder private constructor. How to generate classes with default fields values?
The text was updated successfully, but these errors were encountered: