Closed dojcsak closed 6 years ago
Hi dojcsak,
Thank you for your contribution.
I would love to add it to PB, but I guess we need to change it a little bit since I don't want to enforce a runtime dependency to PB classes.
That means, we can't use PB classes inside the generated builder's source code.
So we don't need to create our own copy of @GwtIncompatible
.
Instead I would prefer to handle this case equivalent to the Optional
case, where the user must configure which Optional class (the Guava one or that from Java 8) to use (done by the @GeneratePojoBuilder.withOptionalProperties=<class>
).
I suggest to add a new element to the @GeneratePojoBuilder
annotation, that allows to specify which concrete class to use for marking gwt-incompatible methods.
For example:
@GeneratePojoBuilder(markGwtIncompatible=com.google.gwt.core.shared.GwtIncompatible.class)
public class MyPojo {
...
}
The default value of this element would be Void.class
, which means that those methods wouldn't get marked.
The @GwtIncompatible annotation is a compile time dependency, because the GWT compiler uses it when it translates the source code to JS. The @GeneratePojoBuilder annotation a compile the dependency itself, so there is no runtime dependency on @GwtIncompatible.
Alright, I will recheck this.
Hi mkarneim,
Thank you for your attention.
I agree with elias-adam, @GwtIncompatible is a compile-time dependency. It does not disturb “normal Java” usage. I tested it.
I copied @GwtIncompatible, because of GWT recommendation (in @GwtIncompatible Javadoc): “Since only the name of the annotation matters, Java libraries may use their own copy of this annotation class to avoid adding a compile-time dependency on GWT.”
I like your suggestion about parameterization and I can implement it, but because of GWT recommendation and @GwtIncompatible does not disturb previous usage I think it is the easiest way to add GWT compatibility.
Alright, that looks good. Since only the annotation's name is relevant, I moved it into our own package.
Thank you for your contribution!
Thank you for merged!
Add support for GWT compile.