question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Package private toPb() methods

See original GitHub issue

Is 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:closed
  • Created 4 years ago
  • Comments:7

github_iconTop GitHub Comments

2reactions
nbalicommented, Sep 11, 2019

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 configured com.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.

1reaction
rahulKQLcommented, Jan 31, 2020

@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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found