Is this possible? Or is the only solution the builder? Having a class with 10 fields would mean have to duplicate the 10 fields in the builder so that AutoValue
works. Or via a manual written create function? Or am I missing something?
I just want to create an object of my AutoValue
class outside of the package...
Here's a short example:
@AutoValue
public abstract class Data
{
// Can something like this be auto generated????
public static Data create(String field1, String field2, ...)
{
return new AutoValue_Data(field1, field2, ...);
}
public abstract String field1();
public abstract String field2();
...
@AutoValue.Builder
public abstract static class Builder {
// Or can I tell the builder to create setters for ALL fields
// automatically instead of having to declare them one by one?
public abstract Builder setField1(String field1);
public abstract Builder setField2(String field2);
...
public abstract Data build();
}
}