@Test public void fromObject_shouldTranslateIfMessageIsSpecified() { PersonName name = new PersonName(); name.setGivenName("John"); String [] properties = { "givenName:message" }; UiUtils uiUtils = mock(UiUtils.class); when(uiUtils.message("John")).thenReturn("Translated"); SimpleObject simpleName = SimpleObject.fromObject(name, uiUtils, properties); assertThat((String) simpleName.get("givenName"), is("Translated")); }
public static SimpleObject fromObject(Object fromObject, UiUtils ui, String... propertiesToInclude) { if (fromObject instanceof Collection) { throw new IllegalArgumentException("Can only be called on an object, not a collection"); } Map<String, Set<String>> propertiesByLevel = splitIntoLevels(propertiesToInclude); return (SimpleObject) fromObjectHelper(fromObject, ui, "", propertiesByLevel); }
SimpleObject extends LinkedHashMap<String, Object> { public static SimpleObject fromObject(Object fromObject, UiUtils ui, String... propertiesToInclude) { if (fromObject instanceof Collection) { throw new IllegalArgumentException("Can only be called on an object, not a collection"); } Map<String, Set<String>> propertiesByLevel = splitIntoLevels(propertiesToInclude); return (SimpleObject) fromObjectHelper(fromObject, ui, "", propertiesByLevel); } }
SimpleObject extends LinkedHashMap<String, Object> { public static SimpleObject fromObject(Object fromObject, UiUtils ui, String... propertiesToInclude) { if (fromObject instanceof Collection) { throw new IllegalArgumentException("Can only be called on an object, not a collection"); } Map<String, Set<String>> propertiesByLevel = splitIntoLevels(propertiesToInclude); return (SimpleObject) fromObjectHelper(fromObject, ui, "", propertiesByLevel); } SimpleObject();  SimpleObject(OpenmrsMetadata metadata); }
SimpleObject extends LinkedHashMap<String, Object> { public static SimpleObject fromObject(Object fromObject, UiUtils ui, String... propertiesToInclude) { if (fromObject instanceof Collection) { throw new IllegalArgumentException("Can only be called on an object, not a collection"); } Map<String, Set<String>> propertiesByLevel = splitIntoLevels(propertiesToInclude); return (SimpleObject) fromObjectHelper(fromObject, ui, "", propertiesByLevel); } SimpleObject();  SimpleObject(OpenmrsMetadata metadata); static SimpleObject create(Object... propertyNamesAndValues); static SimpleObject fromObject(Object fromObject, UiUtils ui, String... propertiesToInclude); @SuppressWarnings("unchecked") static List<SimpleObject> fromCollection(Collection<?> fromCollection, UiUtils ui, String... propertiesToInclude); String toJson(); }
SimpleObject extends LinkedHashMap<String, Object> { public static SimpleObject fromObject(Object fromObject, UiUtils ui, String... propertiesToInclude) { if (fromObject instanceof Collection) { throw new IllegalArgumentException("Can only be called on an object, not a collection"); } Map<String, Set<String>> propertiesByLevel = splitIntoLevels(propertiesToInclude); return (SimpleObject) fromObjectHelper(fromObject, ui, "", propertiesByLevel); } SimpleObject();  SimpleObject(OpenmrsMetadata metadata); static SimpleObject create(Object... propertyNamesAndValues); static SimpleObject fromObject(Object fromObject, UiUtils ui, String... propertiesToInclude); @SuppressWarnings("unchecked") static List<SimpleObject> fromCollection(Collection<?> fromCollection, UiUtils ui, String... propertiesToInclude); String toJson();  }