@Test public void testDeserialize() throws Exception { Map<String, Object> theData = new HashMap<>(); theData.put("position", new Position(10, 10).serialize()); theData.put("size", new Size(20, 30).serialize()); Rectangle theRectangle = Rectangle.deserialize(theData); assertTrue(theRectangle.contains(new Position(11, 11))); assertTrue(theRectangle.contains(new Position(10, 10))); assertTrue(theRectangle.contains(new Position(30, 10))); assertTrue(theRectangle.contains(new Position(30, 40))); assertTrue(theRectangle.contains(new Position(10, 40))); assertFalse(theRectangle.contains(new Position(9, 10))); assertFalse(theRectangle.contains(new Position(31, 10))); assertFalse(theRectangle.contains(new Position(31, 40))); assertFalse(theRectangle.contains(new Position(9, 40))); assertFalse(theRectangle.contains(new Position(9, 9))); assertFalse(theRectangle.contains(new Position(31, 9))); assertFalse(theRectangle.contains(new Position(31, 41))); assertFalse(theRectangle.contains(new Position(9, 41))); }
public static Rectangle deserialize(Map<String, Object> aSerializedData) { Position thePosition = Position.deserialize((Map<String, Object>) aSerializedData.get("position")); Size theSize = Size.deserialize((Map<String, Object>) aSerializedData.get("size")); return new Rectangle(thePosition, theSize); }
Rectangle implements Distributable { public static Rectangle deserialize(Map<String, Object> aSerializedData) { Position thePosition = Position.deserialize((Map<String, Object>) aSerializedData.get("position")); Size theSize = Size.deserialize((Map<String, Object>) aSerializedData.get("size")); return new Rectangle(thePosition, theSize); } }
Rectangle implements Distributable { public static Rectangle deserialize(Map<String, Object> aSerializedData) { Position thePosition = Position.deserialize((Map<String, Object>) aSerializedData.get("position")); Size theSize = Size.deserialize((Map<String, Object>) aSerializedData.get("size")); return new Rectangle(thePosition, theSize); } Rectangle();  Rectangle(Position aPosition, Size aSize); }
Rectangle implements Distributable { public static Rectangle deserialize(Map<String, Object> aSerializedData) { Position thePosition = Position.deserialize((Map<String, Object>) aSerializedData.get("position")); Size theSize = Size.deserialize((Map<String, Object>) aSerializedData.get("size")); return new Rectangle(thePosition, theSize); } Rectangle();  Rectangle(Position aPosition, Size aSize); boolean contains(Position aPosition); Rectangle newPosition(Position aNewPosition); Rectangle newSize(Size aNewSize); @Override Map<String, Object> serialize(); static Rectangle deserialize(Map<String, Object> aSerializedData); }
Rectangle implements Distributable { public static Rectangle deserialize(Map<String, Object> aSerializedData) { Position thePosition = Position.deserialize((Map<String, Object>) aSerializedData.get("position")); Size theSize = Size.deserialize((Map<String, Object>) aSerializedData.get("size")); return new Rectangle(thePosition, theSize); } Rectangle();  Rectangle(Position aPosition, Size aSize); boolean contains(Position aPosition); Rectangle newPosition(Position aNewPosition); Rectangle newSize(Size aNewSize); @Override Map<String, Object> serialize(); static Rectangle deserialize(Map<String, Object> aSerializedData); final Position position; final Size size; }