Reputation: 1078
I'm porting an SDK from Android to plain Java and have run into an AutoParcel annotation that I don't understand.
Here's the original class and a snippet below:
@AutoParcel.Builder
public abstract static class Builder {
public abstract Builder id(String id);
...
public abstract SimpleFeature build();
}
public static Builder builder() {
return new AutoParcel_SimpleFeature.Builder();
}
I am able to pretty much port everything to AutoValue without incident, except that last function, as I don't understand what it is or it's equivalent in AutoValue.
Can someone explain what this is, and what its equivalent is in AutoValue?
Upvotes: 2
Views: 2062
Reputation: 1078
As JohnWowUs' comment suggests, this was largely an Eclipse issue.
The link he mentioned was only part of the solution, but I didn't need to drop more JARs into the project. With the help of an issue in the AutoValue repo and specifically configuring the maven-compiler-plugin, setting JDK1.7 as a target, with the following section added to the pom.xml:
<annotationProcessors>
<annotationProcessor>com.google.auto.value.processor.AutoValueProcessor</annotationProcessor>
</annotationProcessors>
Upvotes: 2
Reputation: 3083
The build annotation allows you to construct the immutable POJOs using the builder pattern i.e. something like
SimpleFeature.builder().id("test").build()
The equivalent annotation (not surprisingly since AutoParcel is a port of Autovalue with android specific features i.e. Parcelable)
@AutoValue.Builder
You should be able to find much more comprehensive documentation at https://github.com/google/auto/tree/master/value#builders
Upvotes: 2