@Test public void testSerialize() throws Exception { Animation theAnimation = new Animation("Test").addToAnimationSequence(new ResourceName("1")).addToAnimationSequence(new ResourceName("2")); Map<String, Object> theData = theAnimation.serialize(); assertEquals(3, theData.size()); assertEquals("Test", theData.get("name")); assertEquals(theAnimation.getUuid(), theData.get("uuid")); List<Map<String, Object>> theAnimationSequence = (List<Map<String, Object>>) theData.get("animationSequence"); assertEquals(2, theAnimationSequence.size()); Map<String, Object> theEntry1 = theAnimationSequence.get(0); assertEquals("1", theEntry1.get("name")); Map<String, Object> theEntry2 = theAnimationSequence.get(1); assertEquals("2", theEntry2.get("name")); }
@Override public Map<String, Object> serialize() { Map<String, Object> theResult = new HashMap<>(); theResult.put("uuid", uuid); theResult.put("name", name); List<Map<String, Object>> theResources = new ArrayList<>(); for (ResourceName theName : animationSequence) { theResources.add(theName.serialize()); } theResult.put("animationSequence", theResources); return theResult; }
Animation implements Distributable { @Override public Map<String, Object> serialize() { Map<String, Object> theResult = new HashMap<>(); theResult.put("uuid", uuid); theResult.put("name", name); List<Map<String, Object>> theResources = new ArrayList<>(); for (ResourceName theName : animationSequence) { theResources.add(theName.serialize()); } theResult.put("animationSequence", theResources); return theResult; } }
Animation implements Distributable { @Override public Map<String, Object> serialize() { Map<String, Object> theResult = new HashMap<>(); theResult.put("uuid", uuid); theResult.put("name", name); List<Map<String, Object>> theResources = new ArrayList<>(); for (ResourceName theName : animationSequence) { theResources.add(theName.serialize()); } theResult.put("animationSequence", theResources); return theResult; } Animation(String aName); private  Animation(String aUUID, String aName, ResourceName[] aAnimationSequence); }
Animation implements Distributable { @Override public Map<String, Object> serialize() { Map<String, Object> theResult = new HashMap<>(); theResult.put("uuid", uuid); theResult.put("name", name); List<Map<String, Object>> theResources = new ArrayList<>(); for (ResourceName theName : animationSequence) { theResources.add(theName.serialize()); } theResult.put("animationSequence", theResources); return theResult; } Animation(String aName); private  Animation(String aUUID, String aName, ResourceName[] aAnimationSequence); String getName(); String getUuid(); Animation changeName(String aName); Animation addToAnimationSequence(ResourceName aName); Animation removeFromAnimationSequence(ResourceName aName); Animation removeFromAnimationSequence(int aIndex); int getSequenceSize(); ResourceName getResourceByIndex(int aIndex); ResourceName computeCurrentFrame(long aGameTime, Integer aSpeed); @Override Map<String, Object> serialize(); static Animation deserialize(Map<String, Object> aData); }
Animation implements Distributable { @Override public Map<String, Object> serialize() { Map<String, Object> theResult = new HashMap<>(); theResult.put("uuid", uuid); theResult.put("name", name); List<Map<String, Object>> theResources = new ArrayList<>(); for (ResourceName theName : animationSequence) { theResources.add(theName.serialize()); } theResult.put("animationSequence", theResources); return theResult; } Animation(String aName); private  Animation(String aUUID, String aName, ResourceName[] aAnimationSequence); String getName(); String getUuid(); Animation changeName(String aName); Animation addToAnimationSequence(ResourceName aName); Animation removeFromAnimationSequence(ResourceName aName); Animation removeFromAnimationSequence(int aIndex); int getSequenceSize(); ResourceName getResourceByIndex(int aIndex); ResourceName computeCurrentFrame(long aGameTime, Integer aSpeed); @Override Map<String, Object> serialize(); static Animation deserialize(Map<String, Object> aData);  }