title: Java 8, Lambda : replace Anonymous inner class by lambda
body: <p>I've got a class which contains the following: </p>
  
  <pre><code>List roles = ldapTemplate.search(baseDn, replaceFilter, sc,
              new AttributesMapper() {
                  public Object mapFromAttributes(Attributes attrs)
                          throws NamingException {
                      return attrs.get("cn").get();
                  }
              });
  </code></pre>
  
  <p>IntelliJ tells me to replace the anonymous inner class with a lambda.
  So I tried: </p>
  
  <pre><code>List roles = ldapTemplate.search(
      baseDn, replaceFilter, sc,
      (Attributes a)  -&gt; { return a.get("cn").get(); };
  );
  </code></pre>
  
  <p>However, I get a compilation error:</p>
  
  <pre><code>Error:(46, 50) java: incompatible types: inference variable T has incompatible bounds
      equality constraints: java.lang.String
      lower bounds: java.lang.Object
  </code></pre>
  
  <p>I can't find the solution to this problem. Do you have any ideas?</p>