Back to project page ExpertAndroid.
The source code is released under:
MIT License
If you think the Android project ExpertAndroid listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.iuriio.demos.expertandroid.ch4gsonserialization; /*from w w w . j a va2s . c om*/ import java.util.ArrayList; public class MainObject { public int intValue = 5; public String strinValue = "st<ri>\"ng\"Value<node1>test</node2>"; public String[] stringArray; public ArrayList<ChildObject> childList = new ArrayList<ChildObject>(); public void addChild(ChildObject co) { childList.add(co); } public void populateStringArray() { stringArray = new String[2]; stringArray[0] = "first"; stringArray[1] = "second"; } public static MainObject createTestMainObject() { MainObject mo = new MainObject(); mo.populateStringArray(); mo.addChild(new ChildObject("Adam",30)); mo.addChild(new ChildObject("Eve",28)); return mo; } public static String checkTestMainObject(MainObject mo) { MainObject moCopy = createTestMainObject(); if (!(mo.strinValue.equals(moCopy.strinValue))) { return "String values don't match:" + mo.strinValue; } if (mo.childList.size() != moCopy.childList.size()) { return "array list size doesn't match"; } //get first child ChildObject firstChild = mo.childList.get(0); ChildObject firstChildCopy = moCopy.childList.get(0); if (!firstChild.name.equals(firstChildCopy.name)) { return "first child name doesnt match"; } return "everything matches"; } }