Last active
          August 29, 2015 14:11 
        
      - 
      
- 
        Save ajermakovics/cdcb553497e301511a73 to your computer and use it in GitHub Desktop. 
    AsyncMapLoader.java
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | interface Loader<T> { | |
| void add(T element); | |
| boolean isFinished(); | |
| } | |
| interface MapLoader<K, V> { | |
| void loadAllKeys(Loader<K> loader); | |
| } | |
| class MyMapLoader<String, String> { | |
| void loadAllKeys(Loader<String> loader) { | |
| final Connection conn = connect(); | |
| final ResultSet rs = query(conn); | |
| while( rs.next() && !loader.isFinished() ) | |
| loader.add( rs.getString("Id") ); | |
| rs.close(); | |
| conn.close(); | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment