title: List to Hashmap using lambda expression
body: <p>Can you please help me to construct Hashmap with Objects from ArrayList.</p>
  
  <pre><code>public class Store {
  
      private int storeId;
      private String storeName;
      private int deliveryDays;
      private List&lt;String&gt; servingZipCodes;
      private StoreAddress storeAddress;
  
  
      public Store() {
      }
  
      public Store(int storeId,String storeName,int deliveryDays,List&lt;String&gt; servingZipCodes,StoreAddress storeAddress){
          this.storeId = storeId;
          this.storeName=storeName;
          this.deliveryDays=deliveryDays;
          this.servingZipCodes=servingZipCodes;
          this.storeAddress = storeAddress;
      }
  
  //getters and setters.
  }
  </code></pre>
  
  <p>And the StoreAddress class </p>
  
  <pre><code>public class StoreAddress {
  
      private String streetAddress1;
      private String streetAddress2;
      private String streetAddress3;
      private String city;
      private String state;
      private String postalCode;
      private String country;
      private String phone;
  
      public StoreAddress() {
      }
  
      public StoreAddress(String streetAddress1, String streetAddress2, String streetAddress3, String city, String state, String postalCode, String country, String phone) {
          this.streetAddress1 = streetAddress1;
          this.streetAddress2 = streetAddress2;
          this.streetAddress3 = streetAddress3;
          this.city = city;
          this.state = state;
          this.postalCode = postalCode;
          this.country = country;
          this.phone = phone;
      }
  </code></pre>
  
  <p>Here is the Test class to for testing.</p>
  
  <pre><code>public class Test {
  
      public static void main(String args[]){
  
          List&lt;Store&gt; storeList=new ArrayList();
          StoreAddress storeAddress1 = new StoreAddress("1500 Polaris Pkwy",null,null,"Columbus","OH","43240","US","9165452345");
          StoreAddress storeAddress2 = new StoreAddress("160 Easton Town Center",null,null,"Columbus","OH","43240","US","9165452345");
          storeList.add(new Store(1,"Store 1",7,new ArrayList&lt;String&gt;(Arrays.asList("43240","43241","43242")),storeAddress1));
          storeList.add(new Store(2,"Store 2",7,new ArrayList&lt;String&gt;(Arrays.asList("43240","43082","43081")),storeAddress2));
          Map&lt;String,List&lt;Store&gt;&gt; zipCodeStoreList = null;
          storeList.forEach(store -&gt; {
              List&lt;String&gt; servingZipCodes = store.getServingZipCodes();
              servingZipCodes.stream().filter(x -&gt; x.matches(store.getStoreAddress().getPostalCode().substring(0,5))).map(x -&gt;new HashMap&lt;String, Object&gt;(){{
                  put(x, store);
              }});
          });
  </code></pre>
  
  <p>Though its possible in Java 7 but looking for solutions in java 8.</p>
  
  <pre><code>Key: 43240, value: Store1 , Store2
  Key: 43241, value: null
  Key: 43242, value: null
  Key: 43082, value: null
  Key: 43081, value: null
  </code></pre>