0

I have class and builder for it.

Builder would be used only in test code and I would like not to have it in production code.

My class:

public class MyClassThatIWantBuilderFor {
  // many fields that I want initialize using builder instead of 10 arg constructor
}

My test case:

public class MyTest {
  // I want to have builder for MyClassThatIWantBuilderFor class here
}

How to achieve it in auto-value?

pixel
  • 24,905
  • 36
  • 149
  • 251
  • This isn't clear what you're asking. – Justin Mitchell Nov 24 '16 at 09:22
  • what is the purpose of `MyClassThatIWantBuilderFor` ? – Blackbelt Nov 24 '16 at 09:40
  • @Blackbelt This is my model class that has approx. 10 fields in constructor and I want to have builder for it. – pixel Nov 24 '16 at 09:47
  • it is really unclear to me as well. What do you mean by *I would like not to have it in production code* ? If you don't want it in `main/` put that only in your test project? – Blackbelt Nov 24 '16 at 09:49
  • @Blackbelt I want to have builder in test code and model class in production code, since I would use builder only in tests. The reason for such approach is dreaded 65k method limit in Android... – pixel Nov 24 '16 at 09:51
  • isn't the multidex support an option for you? – Blackbelt Nov 24 '16 at 09:55
  • @Blackbelt Due to variety of devices multidex support causes many problems - on some low-end devices startup time can increase to 2-3s. There are also buggy devices that crash when multidex is enabled ( Samsung Galaxy S5). That's why I want to fit into 65k method limit and do such things like this one stated in my question. – pixel Nov 24 '16 at 09:58
  • I still don't know what you mean by auto-value.. like deserializing? single constructor? That part makes no sense, but what you said above, sounds like you want to be able to deserialize a model.. ? – Justin Mitchell Nov 24 '16 at 10:16
  • @JustinMitchell by auto-value I mean library made by Google https://github.com/google/auto/blob/master/value/userguide/builders.md – pixel Nov 24 '16 at 10:29
  • Ok so why dont you implement the builder pattern yourself? Also why would you test different functionality than production? Thats not going to help much. – Justin Mitchell Nov 24 '16 at 10:34

0 Answers0