Converting List<Map<String, Object>> to Map<String, Integer>
<p>I am using <a href="http://static.springsource.org/spring/docs/2.0.x/api/org/springframework/jdbc/core/JdbcTemplate.html#queryForList%28java.lang.String%29" rel="nofollow">queryForList</a> to get a table from my database, which gives me <code>List&lt;Map&lt;String, Object&gt;&gt;</code>. I want to use the two column I select to convert this to a <code>Map&lt;String, Integer&gt;</code>. </p>

<p>At the moment I am doing this</p>

<pre><code>List&lt;Map&lt;String, Object&gt;&gt; customers = jdbc.queryForList("SELECT id, name FROM customers");

Map&lt;String, Integer&gt; customerMap = new HashMap&lt;String, Integer&gt;();

for (Map&lt;String, Object&gt; each : customers)
{
    String name = ((String)each.get("name")).trim();
    Integer id = Integer.valueOf(((BigDecimal)each.get("id")).intValue());

    customerMap.put(name, id);
}
</code></pre>

<p>and wondered if there was a better way. Thanks</p>
