facebook

MyEclipse IDE 10.7.1 Getter and Setter Generation

  1. MyEclipse Archived
  2.  > 
  3. Bugs
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #339242 Reply

    There seems to be an issue generating the getters and setters for variable names that only have 1 char in the first part of the variable name before the camel case. For example:

    
    private Integer sEcho;
    

    This generates as:

    
        public Integer getsEcho() {
            return sEcho;
        }
    
        public void setsEcho(Integer sEcho) {
            this.sEcho = sEcho;
        }
    

    This causes Struts to not be able to set the properties to my struts action. Notice the lowercase “s” right after the get and set. It should be:

    
        public Integer getSEcho() {
            return sEcho;
        }
    
        public void setSEcho(Integer sEcho) {
            this.sEcho = sEcho;
        }
    

    Thanks,

    Paul

    #339251 Reply

    It looks like this is a eclipse issues, kind of….They are leaving the functionality as is after some debate. I am getting burned by it currently. I have to define the vars like this because of the DataTables JS lib that sends these naming conventions.

    I just ran into a situation where Struts wants the first char upper case, and the Common Bean Utils wants the first letter lower case like eclipse generated in the first place. I now currently have my gets and sets generated both ways to get it to work 🙁

    https://bugs.eclipse.org/bugs/show_bug.cgi?id=322223

    #339312 Reply

    support-tony
    Keymaster

    Paul,

    This is a tricky one. It looks like the eclipse developers have gone for conformance to JavaBean conventions, as mentioned in this bug. However, the base Java conventions would seem to imply that the alternative naming (uppercase first letter in all cases), as mentioned in the bug you linked to.

    As you’ve seen, different frameworks have conflicting conventions that need to be adhered to, so it’s difficult to see which should be the correct format. You seem to have to effectively duplicate getters and setters, using both conventions, at least in the case of property names having the single lowercase starting letter, to get round these issues.

    I’m not sure there is anything more that can be done, given that one naming strategy will be wrong in some cases and the other naming strategy will be wrong in other cases.

    If you have further suggestions on this, do let us know.

Viewing 3 posts - 1 through 3 (of 3 total)
Reply To: MyEclipse IDE 10.7.1 Getter and Setter Generation

You must be logged in to post in the forum log in