@Test public void toProperties() { Person object = new Person(); object.emails = Arrays.asList("hola@sample.com"); object.address = Arrays.asList(new Address("calle", "17")); final Map<String, Object> properties = mapper.toProperties(object); final Map<String, Object> ad = new HashMap<>(); ad.put("street", "calle"); ad.put("number", "17"); ASSERT.that(properties.get("emails")).isEqualTo(Arrays.asList("hola@sample.com")); ASSERT.that(properties.get("address")).isEqualTo(Arrays.asList(ad)); }
@Override public Map<String, Object> toProperties(Person object) { final Map<String, Object> properties = new HashMap<>(); properties.put("type", "person"); properties.put("emails", object.emails); final List<Map<String, Object>> propertiesAddress; if (object.address == null) { propertiesAddress = null; } else { propertiesAddress = new ArrayList<>(object.address.size()); for (Address address : object.address) { propertiesAddress.add(addressMapper.toProperties(address)); } } properties.put("address", propertiesAddress); return properties; }
Person implements Mapper<Person> { @Override public Map<String, Object> toProperties(Person object) { final Map<String, Object> properties = new HashMap<>(); properties.put("type", "person"); properties.put("emails", object.emails); final List<Map<String, Object>> propertiesAddress; if (object.address == null) { propertiesAddress = null; } else { propertiesAddress = new ArrayList<>(object.address.size()); for (Address address : object.address) { propertiesAddress.add(addressMapper.toProperties(address)); } } properties.put("address", propertiesAddress); return properties; } }
Person implements Mapper<Person> { @Override public Map<String, Object> toProperties(Person object) { final Map<String, Object> properties = new HashMap<>(); properties.put("type", "person"); properties.put("emails", object.emails); final List<Map<String, Object>> propertiesAddress; if (object.address == null) { propertiesAddress = null; } else { propertiesAddress = new ArrayList<>(object.address.size()); for (Address address : object.address) { propertiesAddress.add(addressMapper.toProperties(address)); } } properties.put("address", propertiesAddress); return properties; }  }
Person implements Mapper<Person> { @Override public Map<String, Object> toProperties(Person object) { final Map<String, Object> properties = new HashMap<>(); properties.put("type", "person"); properties.put("emails", object.emails); final List<Map<String, Object>> propertiesAddress; if (object.address == null) { propertiesAddress = null; } else { propertiesAddress = new ArrayList<>(object.address.size()); for (Address address : object.address) { propertiesAddress.add(addressMapper.toProperties(address)); } } properties.put("address", propertiesAddress); return properties; }  @Override Person toObject(Map<String, Object> properties); @Override Map<String, Object> toProperties(Person object); }
Person implements Mapper<Person> { @Override public Map<String, Object> toProperties(Person object) { final Map<String, Object> properties = new HashMap<>(); properties.put("type", "person"); properties.put("emails", object.emails); final List<Map<String, Object>> propertiesAddress; if (object.address == null) { propertiesAddress = null; } else { propertiesAddress = new ArrayList<>(object.address.size()); for (Address address : object.address) { propertiesAddress.add(addressMapper.toProperties(address)); } } properties.put("address", propertiesAddress); return properties; }  @Override Person toObject(Map<String, Object> properties); @Override Map<String, Object> toProperties(Person object); public Address addressMapper; }