2

I have a interface having getter methods like below

public interface IAddress {
  AddressId getId();
  String getCity();
  String getCountry();
}

I want to create another class where I want to reference the getter methods of IAddress like IAddress::getId .

How can I achieve this in JCodeModel?

Sneha
  • 317
  • 4
  • 15
  • 3
    You don’t. Unless there will be a new version of that library supporting Java 8 features. The project page doesn’t look that promising… – Holger Mar 01 '17 at 12:19
  • @Holger Thanks for the info.. anyways could you suggest then how shall I refer an existing method by name.. i.e. `IAddress.getId()` – Sneha Mar 01 '17 at 15:08
  • 1
    A method reference is just an idiom for creating an instance of a functional interface implementation calling the specified method. I’m sure that you can create that using the conventional way, i.e. creating a class implementing the interface and adding an implementation method that will invoke the target method, via codemodel. – Holger Mar 01 '17 at 15:58
  • You might check with this project for newer Java 8 features: https://github.com/phax/jcodemodel – John Ericksen Apr 05 '17 at 20:55

0 Answers0