@Test public void testCreateRestrictedEntity() { JsonNode result = JsonUtils.createRestrictedEntity(dummyObj, "nestedDummy"); Assert.assertEquals(1, result.size()); Assert.assertTrue(result.has("nestedDummy")); Assert.assertEquals(2, result.get("nestedDummy").size()); }
public static JsonNode createRestrictedEntity(JsonApiIdentifiable entity, List<String> properties) { ObjectNode originalNode = objectMapper.valueToTree(entity); ObjectNode restrictedNode = objectMapper.createObjectNode(); properties.forEach(propertyName -> restrictedNode.set(propertyName, originalNode.get(propertyName))); return restrictedNode; }
JsonUtils { public static JsonNode createRestrictedEntity(JsonApiIdentifiable entity, List<String> properties) { ObjectNode originalNode = objectMapper.valueToTree(entity); ObjectNode restrictedNode = objectMapper.createObjectNode(); properties.forEach(propertyName -> restrictedNode.set(propertyName, originalNode.get(propertyName))); return restrictedNode; } }
JsonUtils { public static JsonNode createRestrictedEntity(JsonApiIdentifiable entity, List<String> properties) { ObjectNode originalNode = objectMapper.valueToTree(entity); ObjectNode restrictedNode = objectMapper.createObjectNode(); properties.forEach(propertyName -> restrictedNode.set(propertyName, originalNode.get(propertyName))); return restrictedNode; } private  JsonUtils(); }
JsonUtils { public static JsonNode createRestrictedEntity(JsonApiIdentifiable entity, List<String> properties) { ObjectNode originalNode = objectMapper.valueToTree(entity); ObjectNode restrictedNode = objectMapper.createObjectNode(); properties.forEach(propertyName -> restrictedNode.set(propertyName, originalNode.get(propertyName))); return restrictedNode; } private  JsonUtils(); static JsonNode createRestrictedEntity(JsonApiIdentifiable entity, List<String> properties); static JsonNode createRestrictedEntity(JsonApiIdentifiable entity, String property); }
JsonUtils { public static JsonNode createRestrictedEntity(JsonApiIdentifiable entity, List<String> properties) { ObjectNode originalNode = objectMapper.valueToTree(entity); ObjectNode restrictedNode = objectMapper.createObjectNode(); properties.forEach(propertyName -> restrictedNode.set(propertyName, originalNode.get(propertyName))); return restrictedNode; } private  JsonUtils(); static JsonNode createRestrictedEntity(JsonApiIdentifiable entity, List<String> properties); static JsonNode createRestrictedEntity(JsonApiIdentifiable entity, String property);  }