I need to instantiate a lot of fields in a "lazy" way. Is there any plugin for Android Studio that could generate getters with lazy instantiation and make my life easier? I need my getter to look like this:
public String getName() {
if(mName == null){
mName = "Some value here"
}
return mName;
}
Go to the class you want to implement the getters and setters, hit ctrl + insert and a dialog will appear, click "Getter" or "Setter" and choose the variables you want to implement getters/setters for.
This also works for Override and Implement methods from classes you extend.
Hope this helps, happy coding.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.