code_junkie

Type safety: Unchecked cast

Nov 12th, 2011
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. <util:map id="someMap" map-class="java.util.HashMap" key-type="java.lang.String" value-type="java.lang.String">
  2. <entry key="some_key" value="some value" />
  3. <entry key="some_key_2" value="some value" />
  4. </util:map>
  5.  
  6. private Map<String, String> someMap = new HashMap<String, String>();
  7. someMap = (HashMap<String, String>)getApplicationContext().getBean("someMap");
  8.  
  9. private Map<String, String> someMap = (HashMap<String, String>)getApplicationContext().getBean("someMap");
  10.  
  11. if(getApplicationContext().getBean("someMap") instanceof HashMap) {
  12. private Map<String, String> someMap = (HashMap<String, String>)getApplicationContext().getBean("someMap");
  13. }
  14.  
  15. @SuppressWarnings (value="unchecked")
  16.  
  17. someMap=getApplicationContext().getBean<HashMap<String, String>>("someMap");
Add Comment
Please, Sign In to add comment