The Customer class uses constructor injection (recommended over field injection), but the instance field is not usable inside a lambda.
@Component
public class Customer {
  private final Account account;
  @Autowired
  public Customer(final Account account) {
    this.account = account;
  }
  // Works perfectly fine
  Callable propCallable = new Callable<String>(){
    @Override
    public String call() throws Exception {
        return account.accountId();
    }
  };
  //Shows warning : Variable account might not have been initialized
  Callable lambdaCallable = () -> {
    return account.accountId();
  };
}
I'm just curious to know if there is a better way to use instance variable inside the lambda, rather than anonymous class?
Note: I prefer to keep account as final.
Thanks in advance
 
     
     
    