Yes, you can get rid of the no-arg constructor and control visibility for map and tuple constructors but can't currently control visibility for the no-arg constructor. We'd need an annotation attribute something like what you suggested. It's a little strange in that the visibilityId would control visibility for both the map and no-arg variations unless the noArgVisibilityId attribute was set. Also, if you set noArg=false for @MapConstructor and defaults=true for @TupleConstructor, you get the no-arg constructor from the tuple constructor defaults with no way to set the visibility independently for the 2 or more related constructors.
import groovy.transform.* import static groovy.transform.options.Visibility.PRIVATE @Immutable @MapConstructor(noArg=false) @TupleConstructor(defaults=true, visibilityId='hidden') @VisibilityOptions(id = 'hidden', value = PRIVATE) class Foo { String a, b, c } assert Foo.declaredConstructors*.modifiers == [2, 2, 2, 2, 1] Cheers, Paul. <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> Virus-free. www.avast.com <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> <#m_-1155727755934344353_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2> On Tue, Oct 6, 2020 at 10:49 PM Damir Murat <damir.mu...@gmail.com> wrote: > Yes, I could benefit from static factory methods. Thanks for giving me an > idea. > But I was thinking only about restricting the visibility of the default > no-arg constructor. > > As both @MapConstructor and @TupleConstructor have a visibilityId > parameter used > for fine-grained tuning of visibility, I expected a similar option for the > default no-arg > constructor too. Maybe something like the noArgVisibilityId parameter in > @MapConstructor. > > Tnx, > Damir > <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> Virus-free. www.avast.com <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>