@Test public void testGetValueOneLevel() { Map<String, Object> data = new HashMap<String, Object>(); data.put("key1", "value1"); data.put("key2", "value2"); data.put("key3", "value3"); assertEquals("Should match", "value1", apiNeutralSchemaValidator.getValue("key1", data)); assertEquals("Should match", "value2", apiNeutralSchemaValidator.getValue("key2", data)); assertEquals("Should match", "value3", apiNeutralSchemaValidator.getValue("key3", data)); assertEquals("Should match", null, apiNeutralSchemaValidator.getValue("key4", data)); }
protected Object getValue(String path, Map<String, Object> data) { Object retValue = null; Map<?, ?> values = new HashMap<String, Object>(data); String[] keys = path.split("\\."); for (String key : keys) { Object value = values.get(key); if (Map.class.isInstance(value)) { values = (Map<?, ?>) value; retValue = value; } else { retValue = value; break; } } return retValue; }
ApiNeutralSchemaValidator extends NeutralSchemaValidator { protected Object getValue(String path, Map<String, Object> data) { Object retValue = null; Map<?, ?> values = new HashMap<String, Object>(data); String[] keys = path.split("\\."); for (String key : keys) { Object value = values.get(key); if (Map.class.isInstance(value)) { values = (Map<?, ?>) value; retValue = value; } else { retValue = value; break; } } return retValue; } }
ApiNeutralSchemaValidator extends NeutralSchemaValidator { protected Object getValue(String path, Map<String, Object> data) { Object retValue = null; Map<?, ?> values = new HashMap<String, Object>(data); String[] keys = path.split("\\."); for (String key : keys) { Object value = values.get(key); if (Map.class.isInstance(value)) { values = (Map<?, ?>) value; retValue = value; } else { retValue = value; break; } } return retValue; }  }
ApiNeutralSchemaValidator extends NeutralSchemaValidator { protected Object getValue(String path, Map<String, Object> data) { Object retValue = null; Map<?, ?> values = new HashMap<String, Object>(data); String[] keys = path.split("\\."); for (String key : keys) { Object value = values.get(key); if (Map.class.isInstance(value)) { values = (Map<?, ?>) value; retValue = value; } else { retValue = value; break; } } return retValue; }  @Override boolean validateNaturalKeys(final Entity entity, boolean overWrite); }
ApiNeutralSchemaValidator extends NeutralSchemaValidator { protected Object getValue(String path, Map<String, Object> data) { Object retValue = null; Map<?, ?> values = new HashMap<String, Object>(data); String[] keys = path.split("\\."); for (String key : keys) { Object value = values.get(key); if (Map.class.isInstance(value)) { values = (Map<?, ?>) value; retValue = value; } else { retValue = value; break; } } return retValue; }  @Override boolean validateNaturalKeys(final Entity entity, boolean overWrite);  }