Last active
January 3, 2016 14:19
-
-
Save patrickhammond/8475157 to your computer and use it in GitHub Desktop.
Sample usage of: https://github.com/johncarl81/parceler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Compiled files: | |
SamplePojoTest$SamplePojo$$Parcelable$1.class | |
SamplePojoTest$SamplePojo$$Parcelable$Parcelable$Creator$$0.class | |
SamplePojoTest$SamplePojo$$Parcelable.class | |
SamplePojoTest$SamplePojo.class | |
SamplePojoTest.class | |
Output from: javap SamplePojoTest\$SamplePojo | |
Compiled from "SamplePojoTest.java" | |
public class com.atomicrobot.floss.SamplePojoTest$SamplePojo { | |
public com.atomicrobot.floss.SamplePojoTest$SamplePojo(java.lang.String); | |
public java.lang.String getName(); | |
} | |
Output from: javap SamplePojoTest\$SamplePojo\$\$Parcelable | |
public class com.atomicrobot.floss.SamplePojoTest$SamplePojo$$Parcelable implements android.os.Parcelable, org.parceler.ParcelWrapper<com.atomicrobot.floss.SamplePojoTest$SamplePojo> { | |
public static final com.atomicrobot.floss.SamplePojoTest$SamplePojo$$Parcelable$Parcelable$Creator$$0 CREATOR; | |
public com.atomicrobot.floss.SamplePojoTest$SamplePojo$$Parcelable(android.os.Parcel); | |
public com.atomicrobot.floss.SamplePojoTest$SamplePojo$$Parcelable(com.atomicrobot.floss.SamplePojoTest$SamplePojo); | |
public void writeToParcel(android.os.Parcel, int); | |
public int describeContents(); | |
public com.atomicrobot.floss.SamplePojoTest$SamplePojo getParcel(); | |
public java.lang.Object getParcel(); | |
static {}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.os.Parcelable; | |
import junit.framework.Assert; | |
import org.junit.Test; | |
import org.parceler.Parcel; | |
import org.parceler.ParcelConstructor; | |
import org.parceler.Parcels; | |
public class SamplePojoTest { | |
@Parcel | |
public static class SamplePojo { | |
private String name; | |
@ParcelConstructor | |
public SamplePojo(String name) { | |
this.name = name; | |
} | |
public String getName() { | |
return name; | |
} | |
} | |
@Test | |
public void testParcelling() { | |
SamplePojo pojo = new SamplePojo("Hello!"); | |
Parcelable wrapped = Parcels.wrap(pojo); | |
SamplePojo unwrapped = Parcels.unwrap(wrapped); | |
Assert.assertEquals("Hello!", unwrapped.getName()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment