Closed bnorm closed 8 years ago
Added a failing test for this https://github.com/gabrielittner/auto-value-with/tree/prefixes I'll try to get a fix out later this week.
Any word on this? This is causing a problem with Android's databinding because it requires bean-style getters.
The snapshot is out now, a proper release will be out later today.
i see the test. is there a fix in that PR? i didn't see one when i looked at it. it's still broken for me in 1.2
The fix was part of #17. Can you give me a sample that doesn't work?
want a whole project or just a file?
Just pasting the file in here is enough.
truncated stacktrace:
Error:(14, 17) error: @AutoValue processor threw an exception: java.lang.IllegalArgumentException: com.itworks.mobile.terminator.models.MailingAddress doesn't have property with name street which is required for withStreet()
at com.gabrielittner.auto.value.with.AutoValueWithExtension.getWithMethods(AutoValueWithExtension.java:65)
at com.gabrielittner.auto.value.with.AutoValueWithExtension.applicable(AutoValueWithExtension.java:108)
at com.google.auto.value.processor.AutoValueProcessor.processType(AutoValueProcessor.java:372)
at com.google.auto.value.processor.AutoValueProcessor.process(AutoValueProcessor.java:143)
...
class definition:
package datamodels;
import com.google.auto.value.AutoValue;
import android.databinding.BaseObservable;
import android.databinding.Bindable;
import android.os.Parcelable;
import android.support.annotation.Nullable;
/**
* Created by toadzky on 4/28/16.
*/
@AutoValue
public abstract class MailingAddress extends BaseObservable implements Parcelable {
public static final MailingAddress EMPTY = MailingAddress.builder().build();
@Bindable
public abstract String getStreet();
@Bindable
@Nullable
public abstract String getAdditional();
@Bindable
public abstract String getCity();
@Bindable
public abstract String getDistrict();
@Bindable
public abstract String getCountry();
@Bindable
public abstract String getPostal();
public abstract MailingAddress withStreet(String update);
public abstract MailingAddress withAdditional(String update);
public abstract MailingAddress withCity(String update);
public abstract MailingAddress withDistrict(String update);
public abstract MailingAddress withCountry(String update);
public abstract MailingAddress withPostal(String update);
private Builder toBuilder() {
return new AutoValue_MailingAddress.Builder(this);
}
public static Builder builder() {
return new AutoValue_MailingAddress.Builder();
}
@AutoValue.Builder
public abstract static class Builder {
public abstract Builder street(String street);
public abstract Builder additional(String additional);
public abstract Builder city(String city);
public abstract Builder district(String district);
public abstract Builder country(String country);
public abstract Builder postal(String postal);
public abstract MailingAddress build();
}
}
Does it work when you remove implements Parcelable
?
Yes. I'm using the auto-value-parcel
extension as well. I guess it's an interaction between extensions.
Someone else ran into that issue with auto-value-parcel
+ auto+value-gson
. I've posted a workaround in that issue https://github.com/rharter/auto-value-parcel/issues/47
When messing around with AutoValue and your extension, if a property has a getX() method, this is not handled properly. The generated with method will have the short form method calls - which don't exist - instead of the getX() method calls.
Let me know if you need an example and I can provide one.