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
Extensive (is)
option
#248
Conversation
Also, remove unnecessary imports.
Codecov Report
@@ Coverage Diff @@
## master #248 +/- ##
============================================
+ Coverage 64.55% 64.59% +0.03%
- Complexity 575 579 +4
============================================
Files 309 309
Lines 8098 8106 +8
Branches 557 559 +2
============================================
+ Hits 5228 5236 +8
Misses 2758 2758
Partials 112 112 |
@armiol, PTAL. |
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.
@dmdashenkov LGTM. Let's revert the changes to Gradle binaries in the root. And address a comment before merging.
// | ||
// A generated interface has no declared methods and extends `com.google.protobuf.Message`. | ||
// The `.java` file is placed alongside with the code generated by the proto-to-java compiler. | ||
// If specified with an FQN, the package of the generated type matches the FQN. |
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.
This sentence seems to be a new paragraph, as it's about how to reference a type.
This PR introduces an improvement to the message marker interface declaration. This PR fixes core-java/#911.
Summary
Previously, the only possibility to mark a message with a marker interface was to generate the interface with the help of
protoc
itself.From now on, it is possible for marker interfaces to be handcrafted, instead of generated.
Handcrafted Interfaces
In order to declare that a message Java class should implement an interface, the user should annotate it with
(is)
option as follows:Now, in Java, declare
org.example.customer.FreemiumCustomer
interface:The interface may have any methods and/or extend any other interfaces as long as it does not introduce new abstract methods to the message class. If the method is already present in the end class or has a
default
implementation, it is allowed.Generated Interfaces
In order to generate the marker interface, the
(is).generate
option field should be set totrue
(the default value isfalse
):Note that it is sufficient to specify
generate = true
only once. This detail may be omitted on further message declarations. However, it is OK to specify to generate the interface on all the messages.(every_is)
OptionThe
(every_is)
option is a "brother" of the(is)
option targeting an entiere file instead of a single message type. The API of(every_is)
is the same as the API of(is)
.