-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
**EXPERIMENTAL** Support Parcelable types for Android #127
Comments
Draft implementation is complete, feedback welcome: https://github.com/joelittlejohn/jsonschema2pojo/tree/parcelable Note, this has only been tested with robolectric. |
It would be helpful if someone could test this.
EDIT: I've made a proper config option now, use |
I found that the code lines below generate Parcelable classes which have the annotations("javax.validation.constraints.NotNull", "javax.validation.Valid" ) not available on the Android runtime ruleFactory.getValidRule().apply(nodeName, node, field, schema); ((JFieldVar) generatableType).annotate(NotNull.class); |
Are you able to include the javax.validation/validation-api jar? I really need to create a dedicated config argument for parcelable so that it can be tested more easily. |
Good to hear your feedback. compile 'javax.validation:validation-api:1.0.0.GA' I hope to see new release with Parcelable support is available on maven repository soon. |
BTW, would you consider to introduce new option(other than "includeJsr303Annotations") for Android Parcelable types support when it comes to release this in the future? |
I've just rebased the https://github.com/joelittlejohn/jsonschema2pojo/tree/parcelable Then if you're using Maven, activate the parcelable support like: <parcelable>true</parcelable> gradle, CLI, Ant etc have an equivalent config option. |
@jsuksl @premnirmal @LOG-TAG if you can give this a test and provide some feedback, this would be very helpful. I don't really know if the current implementation approach will work or not. |
@joelittlejohn https://github.com/joelittlejohn/jsonschema2pojo/tree/parcelable works fine. BTW, I see jsonschema2pojo-maven-plugin build fails. |
Thanks @jsuksl! Could you give me some details of how you tested this? What kind of object did you parcel and what environment did you use to test this? Also, I don't see any problems with the build when I run |
I used jsonschema2pojo built from https://github.com/joelittlejohn/jsonschema2pojo/tree/parcelable to convert json schema files(30+) to POJO classes which contains information for UI components. few of the POJO classes are used as a parameter value( "http://developer.android.com/reference/android/content/Intent.html#putExtra(java.lang.String, android.os.Parcelable)" ) and can be written to and restored from Parcel successfully. I encountered the errors below when I run
|
Hmm, I think the assertThat call is confusing the compiler as the varargs are making it ambiguous. I don't see this error when I run the build though. Could you let me know your OS, JDK version and Maven version? |
Here you are
|
The errors have been resolved after letting maven use JDK 1.7
|
I've included 'experimental' support for this in master. People can give this a try and provide some feedback if they have problems. |
thanks! |
This came up on the mailing list, and sounds like it might be very useful for a lot of people:
https://groups.google.com/forum/#!topic/jsonschema2pojo-users/IX0g58VAS58
More details:
http://developer.android.com/reference/android/os/Parcelable.html
The text was updated successfully, but these errors were encountered: