@Test public void testInvalidGet() throws Exception { try { new MapToBeanConverter(getTestMap()).get("foo"); fail("IllegalArgumentException expected!"); } catch (IllegalArgumentException e) { assertTrue(e.getMessage().contains("foo")); } }
public Object get(String key) throws Exception { if (key == null || !key.startsWith(BEAN_ID_PREFIX)) { throw new IllegalArgumentException("Provided key does not start with " + BEAN_ID_PREFIX + ": " + key); } Object result = builtObjectsMap.get(key); if (result == null) { result = build(key); builtObjectsMap.put(key, result); } return result; }
MapToBeanConverter { public Object get(String key) throws Exception { if (key == null || !key.startsWith(BEAN_ID_PREFIX)) { throw new IllegalArgumentException("Provided key does not start with " + BEAN_ID_PREFIX + ": " + key); } Object result = builtObjectsMap.get(key); if (result == null) { result = build(key); builtObjectsMap.put(key, result); } return result; } }
MapToBeanConverter { public Object get(String key) throws Exception { if (key == null || !key.startsWith(BEAN_ID_PREFIX)) { throw new IllegalArgumentException("Provided key does not start with " + BEAN_ID_PREFIX + ": " + key); } Object result = builtObjectsMap.get(key); if (result == null) { result = build(key); builtObjectsMap.put(key, result); } return result; } MapToBeanConverter(Map<String, String> map); }
MapToBeanConverter { public Object get(String key) throws Exception { if (key == null || !key.startsWith(BEAN_ID_PREFIX)) { throw new IllegalArgumentException("Provided key does not start with " + BEAN_ID_PREFIX + ": " + key); } Object result = builtObjectsMap.get(key); if (result == null) { result = build(key); builtObjectsMap.put(key, result); } return result; } MapToBeanConverter(Map<String, String> map); Object get(String key); }
MapToBeanConverter { public Object get(String key) throws Exception { if (key == null || !key.startsWith(BEAN_ID_PREFIX)) { throw new IllegalArgumentException("Provided key does not start with " + BEAN_ID_PREFIX + ": " + key); } Object result = builtObjectsMap.get(key); if (result == null) { result = build(key); builtObjectsMap.put(key, result); } return result; } MapToBeanConverter(Map<String, String> map); Object get(String key); static final String BEAN_ID_PREFIX; static final String DOT; }