I have a little question. I am trying to create templates for getters for my variables inside Eclipse. What I want to do in my getter method is to check if the variable is null or not. If this value is null, I want to assign it a value. However, the problem is that I need to pass the return value of the method to the return type. I could not handle it. Here is the code I would like to have:
Integer someInt; Double someDoub; Long someLong; public Integer getSomeInt(){ if(someInt == null) someInt = (Integer) new Generator().evaluate(); return someInt; } public Double getSomeDoub(){ if(someDoub == null) someDoub = (Double) new Generator().evaluate(); return someDoub; }
This is the code I want to generate. Here is what I typed as a template:
if( ${field} == null){ ${field} = ( ${return_type} ) new Generator().evaluate(); } return ${field};
As soon as I type this. Eclipse says return_type is unknown. Please, help.
Thanks so much for your time.
user793623
source share