Java – eclipse generates getters / setters for domain objects and class members with’m ‘suffixes
I have a small problem with the getter and setter methods generated in my domain object
class User{ String mName; List<Call> mAllCall; List<Geo> mAllGeo;
Unfortunately, I have several classes with more member variables The problem I encountered was that I was a very lazy developer. I created getter and setter methods in eclipse
The result is
public String getmName() { return mName; } public void setmName(String mName) { this.mName = mName; } public List<Call> getmAllCall() { return mAllCall; } public void setmAllCall(List<Call> mAllCall) { this.mAllCall = mAllCall; } public List<Geo> getAllGeo() { return mAllGeo; } public void setmAllGeo(List<Geo> mAllGeo) { this.mAllGeo = mAllGeo; }
That's not what I want I need this:
public String getName() { return mName; } public void setName(String pName) { this.mName = pName; } public List<Call> getAllCall() { return mAllCall; } public void setAllCall(List<Call> pAllCall) { this.mAllCall = pAllCall; } public List<Geo> getAllGeo() { return mAllGeo; } public void setmAllGeo(List<Geo> pAllGeo) { this.mAllGeo = mAllGeo; }
I currently manually delete and replace the prefix in the method name Is there a simpler way?
Solution
For prefix m, add the letter M to the prefix list in the Java code style
Follow these steps:
>Open preferences, > in the left panel, expand Java, > extended code style, > the right panel is where you should see it now
You will see a list of fields, static fields, and so on This is what you need to modify
Set M to fields
Set P as a parameter
Since the name of the field will now be different from the name of the parameter, the Eligibility will no longer be automatically added However, you can use "this" to select the "restrict access to all generated fields" option Once more.
I wonder if you know the difference between enabling project specific settings and configuring workspace settings in the upper left and right corners of the window?