HaloContentInstance implements Parcelable { public static String serialize(@NonNull HaloContentInstance haloContentInstance, @NonNull Parser.Factory parser) throws HaloParsingException { AssertionUtils.notNull(haloContentInstance, "haloContentInstance"); AssertionUtils.notNull(parser, "parser"); try { return ((Parser<HaloContentInstance, String>) parser.serialize(HaloContentInstance.class)).convert(haloContentInstance); } catch (IOException e) { throw new HaloParsingException("Error while serializing the HaloContentInstance", e); } } HaloContentInstance(); @Keep @Api(2.2)  HaloContentInstance(@Nullable String itemId,@Nullable String moduleName,@Nullable String moduleId,
                               @Nullable String name, @Nullable JSONObject values,
                               @Nullable String author, @Nullable Date archivedDate,@Nullable Date createdDate,
                               @Nullable Date updateDate, @Nullable Date publicationDate, @Nullable Date deletionDate,
                               @Nullable List<HaloSegmentationTag> tags); protected  HaloContentInstance(Parcel in); private  HaloContentInstance(@NonNull HaloContentInstance.Builder builder); @Override int describeContents(); @Override void writeToParcel(Parcel dest, int flags); @Keep @Api(2.2) @Nullable String getModuleName(); @Keep @Api(2.0) String getModuleId(); @Keep @Api(2.0) String getItemId(); @Keep @Api(2.0) String getName(); @Keep @Api(2.0) @Nullable JSONObject getValues(); @Keep @Api(2.0) String getAuthor(); @Keep @Api(2.2) List<HaloSegmentationTag> getTags(); @Keep @Api(2.2) @Nullable Date getArchivedDate(); @Keep @Api(2.0) @Nullable Date getCreatedDate(); @Keep @Api(2.0) @Nullable Date getLastUpdate(); @Keep @Api(2.0) @Nullable Date getPublishedDate(); @Keep @Api(2.0) @Nullable Date getRemoveDate(); @Override String toString(); static String serialize(@NonNull HaloContentInstance haloContentInstance, @NonNull Parser.Factory parser); @Nullable static HaloContentInstance deserialize(@Nullable String haloContentInstance, @NonNull Parser.Factory parser); static final Creator<HaloContentInstance> CREATOR; }
@Test public void thatCanSerializeObject() throws JSONException, HaloParsingException { Date now = new Date(); JSONObject json = new JSONObject("{foo: 'bar'}"); HaloContentInstance instance = new HaloContentInstance("fakeId", "fakeModuleName", "fakeModule", "fakeName", json,"fakeAuthor",now, now, now, now, now,new ArrayList<HaloSegmentationTag>()); String objectSerialized = HaloContentInstance.serialize(instance, mHalo.framework().parser()); JSONObject jsonObject = new JSONObject(objectSerialized); assertThat(jsonObject.get("id")).isEqualTo("fakeId"); }