Generate all setXXX calls of a POJO in Eclipse?

前端 未结 5 1549
感动是毒
感动是毒 2021-01-31 03:36

Im currently doing a lot of testing with JPA entities, where i have to keep calling the setter methods on the entity that looks something like this :

myEntity.se         


        
5条回答
  •  感动是毒
    2021-01-31 04:33

    I like @Oscar's answer. It does lead to some cleanup though.

    When I paste from the clipboard, I get something that looks like this:

    setOne(int)  
    setTwo(String)  
    

    In order to clean this up, I first add semicolons with this search/replace regexp:

    search = (.)$
    replace = \1;
    

    Then I add the getter calls (assuming incoming data object is named "data"):

    search = s(et.*)\(.*  
    replace = s\1(data.g\1());  
    

    This doesn't handle multiple arguments in a method call...

提交回复
热议问题