I'm searching for a solution where I can define a field in a class and use the reference in this particular class. The codemodel should create a method for instantiating the field and should replace the field usages with the created method.
I hope somebody can help me.
unprocessed Class
public class MyClass {
@LazyInit
CustomClass member;
public void someMethod() {
System.out.println(member);
}
}
Class after codeModel usage
public class MyClass_ {
@LazyInit
CustomClass member;
public void someMethod() {
System.out.println(getInstanceOfMember());
}
public member getInstanceOfMember() {
if (member == null)
member == new CustomClass();
return member;
}
}