You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ideally, I would like to be able to declare public abstract ImmutableSet.Builder<String> countries() with no suffix at all. Currently it leads to name collision with countries getter (as [AutoValueBuilderReturnType] nicely explains), but I hope that it is still possible to extend the implementation in a backward compatible way. Distinction between getters and builders seems to be rather unambiguous.
The text was updated successfully, but these errors were encountered:
I don't think using the method's return type alone would work in general. What if you had more than one property of type ImmutableSet<String>? We could imagine accepting any suffix on the end of the property name, including the empty suffix, so all these would work:
abstractImmutableSet.Builder<String> countriesBuilder(); // the thing that works todayabstractImmutableSet.Builder<String> countriesAccumulator();
abstractImmutableSet.Builder<String> countries();
That's potentially ambiguous, though, if one property has a name that is a prefix of another.
On the other hand, there's already a fairly simple workaround:
I don't think using the method's return type alone would work in general.
You are right! And thank you for a workaround. However I see one more problem related to name conflicts that didn't came to my mind before. This already doesn't compile:
As for workaround (thanks again!), it obviously forces builder to be an abstract class. With @AutoBuilder and no need for custom logic, it could be an interface. I can't imagine mocking a builder with java.lang.reflect.Proxy, but who knows, what crazy use cases live in the wild...
Hi! I'm looking for a way to declare / use nested property builders with names other than default, but can't make it work. I've read https://github.com/google/auto/blob/main/value/userguide/builders-howto.md#accumulate, yet found nothing related.
Possibility to use anything other than
fooBuilder()
would be great. This probably means that logic would have to be based entirely on method's return type. This seems to be the way it works in the case ofpublic static Builder builder()
which can be renamed freely (https://github.com/google/auto/blob/main/value/userguide/builders-howto.md#-use-different-names-besides-builderbuilderbuild).Ideally, I would like to be able to declare
public abstract ImmutableSet.Builder<String> countries()
with no suffix at all. Currently it leads to name collision with countries getter (as[AutoValueBuilderReturnType]
nicely explains), but I hope that it is still possible to extend the implementation in a backward compatible way. Distinction between getters and builders seems to be rather unambiguous.The text was updated successfully, but these errors were encountered: