0

Is there a possibility to modify Lombok's @Getter for one type of field? There is a MutableLiveData that is child of LiveData. I want Lombok to create getters for MutableLiveData fields that return LiveData not MutableLiveData. I hope you understand what I mean.

To picture what I'm talking about I am adding some code:

public class ViewModelAccount extends ViewModel {

    private MutableLiveData<String> selectedLanguagesReadable = new MutableLiveData<>();

    public LiveData<String> getSelectedLanguagesReadable() {
        return selectedLanguagesReadable;
    }
}

It is about MVVM pattern in Android and removing boilerplate code in ViewModels. Thanks.

Qbi
  • 445
  • 4
  • 13

1 Answers1

1

This answer might help you,

@Getter(AccessLevel.NONE) private boolean hasObject;
public boolean hasObject() {
    return hasObject;
}

i found it here Edit lombok getter method name for boolean member having prefix "has"

  • Thanks but I don't understand how it works and what it does. Could you adjust your suggestion to my example? – Qbi Feb 17 '22 at 17:21