Package private toPb() methods
See original GitHub issueIs there any reason why the toPb()
methods are package private? I have found myself in situations more than once where it would have been beneficial to have them as public.
(… and yes, I can work around it, I’m just curious what is the logic behind this.)
Issue Analytics
- State:
- Created 4 years ago
- Comments:7
Top Results From Across the Web
Controlling Access to Members of a Class - Oracle Help Center
There are two levels of access control: At the top level— public , or package-private (no explicit modifier). At the member level— public ......
Read more >What is the difference between public, protected, package ...
Thus if all constructors are private, the class can only be constructed by code living within the class (typically static factory methods or...
Read more >Public vs Protected vs Package vs Private Access Modifier in ...
So access modifiers are used to set accessibility of classes, methods, and other members. If a class is declared as public then we...
Read more >Package-Private Alternative in Kotlin - Baeldung
Explore alternatives to Java's package private in Kotlin. ... allows using the package-private modifier at the top and member levels.
Read more >Difference between private, protected, public and package ...
you can not use the private modifier on top-level classes. private variables, methods, and classes are only accessible on the class on which...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This might make sense, when it’s very rare that someone wants to work with the actual Protobuf class, but what my issue usually looks like is that the class with the package private method just wraps a similar class from another library which might be actually in use in many projects/services/implementations. For example: https://github.com/googleapis/google-cloud-java/blob/6666cdd62c0957afb5fb450e5fcf0fbe3e427225/google-cloud-clients/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/JobInfo.java#L315-L334 The referenced class might be a Protobuf one - IDK, and haven’t checked -, but TBH that is not the use-case it was needed for. What I needed was a
com.google.api.services.bigquery.model.Job
instance from a previously configuredcom.google.cloud.bigquery.Job
, so I can further use it with code that expects classes from the legacy library, and not this one.Still, okay, let’s say I get it, the goal was to make it as noob-friendly as possible, but then at least make the workaround part of the project itself, and don’t force devs who actually know what are they doing, to do extra work everytime they need to access a package private method.
@nbali Sorry for the late response. I agree with your reasoning.
@kolea2, @ajaaym Would you please let us know your stand on these internal methods