@Test public void testKeyForTarget() { DataObject target = mock(DataObject.class); when(target.readNestedProperty("a")).thenReturn("a1"); when(target.readNestedProperty("b")).thenReturn(5); when(target.readNestedProperty("c")).thenReturn(6); Object key = mapper.keyForTarget(target); assertTrue(key instanceof Map); @SuppressWarnings({ "unchecked", "rawtypes" }) Map<String, Object> keyMap = (Map) key; assertEquals(2, keyMap.size()); assertEquals("a1", keyMap.get("a")); assertEquals(5, keyMap.get("b")); }
@Override public Object keyForTarget(DataObject target) { Map<String, Object> keyMap = new HashMap<>(pathMappers.size() * 2); for (Entry<String, Mapper> e : pathMappers.entrySet()) { keyMap.put(e.getKey(), e.getValue().keyForTarget(target)); } return keyMap; }
MultiPathMapper implements Mapper { @Override public Object keyForTarget(DataObject target) { Map<String, Object> keyMap = new HashMap<>(pathMappers.size() * 2); for (Entry<String, Mapper> e : pathMappers.entrySet()) { keyMap.put(e.getKey(), e.getValue().keyForTarget(target)); } return keyMap; } }
MultiPathMapper implements Mapper { @Override public Object keyForTarget(DataObject target) { Map<String, Object> keyMap = new HashMap<>(pathMappers.size() * 2); for (Entry<String, Mapper> e : pathMappers.entrySet()) { keyMap.put(e.getKey(), e.getValue().keyForTarget(target)); } return keyMap; } MultiPathMapper(Map<String, Mapper> pathMappers); }
MultiPathMapper implements Mapper { @Override public Object keyForTarget(DataObject target) { Map<String, Object> keyMap = new HashMap<>(pathMappers.size() * 2); for (Entry<String, Mapper> e : pathMappers.entrySet()) { keyMap.put(e.getKey(), e.getValue().keyForTarget(target)); } return keyMap; } MultiPathMapper(Map<String, Mapper> pathMappers); @Override Expression expressionForKey(Object key); @Override Object keyForSource(RowProxy source); @Override Object keyForTarget(DataObject target); }
MultiPathMapper implements Mapper { @Override public Object keyForTarget(DataObject target) { Map<String, Object> keyMap = new HashMap<>(pathMappers.size() * 2); for (Entry<String, Mapper> e : pathMappers.entrySet()) { keyMap.put(e.getKey(), e.getValue().keyForTarget(target)); } return keyMap; } MultiPathMapper(Map<String, Mapper> pathMappers); @Override Expression expressionForKey(Object key); @Override Object keyForSource(RowProxy source); @Override Object keyForTarget(DataObject target);  }