google/CallBuilder

Allow specifying "sub-package" within which the generated builder class will reside

Opened this issue · 1 comments

Since all the builder classes that CallBuilder generates are currently dropped into the same namespace, there's a chance that class names will conflict.
To work around that, one can use a longer class name (perhaps prefixed with the name of the method that will be called). This could result, though, in very long class names.

Can you please enhance CallBuilder so that we can specify a sub-package in which the generated builder class will reside?

e.g.

package foo.bar;
class Baz {
    CallBuilder(className="builder.GenerateQuxBuilder")
    public static Qux generateQux();
}

will create foo.bar.builder.GenerateQuxBuilder.
This can then be imported as GenerateQuxBuilder with no risk of conflicts.

Alternatively, you can add an attribute to the annotation to specify the package name separately.

Yes, I agree with this proposal. Specifying the sub-package name wit a separate argument is a more flexible approach (i.e. subpackageName, and later we can add a packageName argument to specify an absolute package path)

I'll get to this eventually - should not be hard to implement. But if you want to send me a PR instead that would be welcome as well!