title: Java 8 Collection stream Collectors.toMap
body: <p>Why this code is not compile for me?</p>
  
  <p>I try to convert List to Map using stream and toMap option</p>
  
  <pre><code>List&lt;CountryToPaymentMethodsDisplayRules&gt;
     paymentMethodDisplayRulesByCountryList = 
         gatway.getCountryPaymentMethodsDisplayRulesByCountry();
  
  Map&lt;PaymentMethod, CountryToPaymentMethodsDisplayRules&gt;
     countryToPaymentMethodsDisplayRulesMap = paymentMethodDisplayRulesByCountryList
         .stream()
         .collect(Collectors.toMap(type -&gt; type.getCountryToPaymentMethodsDisplayRules().getPaymentMethod(),
                                   type -&gt; type));
  
  public interface PaymentMethod extends Serializable {
  }
  
  public enum PaymentMethodType implements PaymentMethod, Serializable {
  }
  
  public interface CountryToPaymentMethodsDisplayRules {
      public PaymentMethod getPaymentMethod();
  }
  
  public class CountryToPaymentMethodsDisplayRulesEntity implements CountryToPaymentMethodsDisplayRules, PersistentEntity&lt;Long&gt;, Serializable {
      @Type(type = "com.plimus.core.payment.PaymentMethodTypeUserType")
      @Column(name = "PAYMENT_TYPE")
      private PaymentMethod paymentMethod;
  }
  </code></pre>
  
  <p>What is wrong here?</p>