Generate all setXXX calls of a POJO in Eclipse?

前端 未结 5 1445
感动是毒
感动是毒 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:28

    Source --> Generate Getters and Setters...

    You can also get at it via the Quick Fix command (Ctrl+1) when the cursor is on a property.


    EDIT

    If you are simply looking for a faster way to copy properties from one object to another I suggest that you look at using reflection. I think this path would be much easier long term then generating the same-looking code over-and-over.

    Commons BeanUtils can take away some of the pain in writing pure reflection code. For example, copyProperties takes a destination bean and either another bean or a Map as the source.

提交回复
热议问题