Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有谁知道如何告诉 Eclipse 为在分配参数之前调用 trim() 的字符串生成 setter 方法?
一个丑陋(!)的方法是在 Workspace -> Preferences -> Java -> Code Style -> Code Templates -> Code -> Setter Body -> Edit 中编写以下内容
if (${param} instanceof String) { ${field} = ${param}.trim(); } else { ${field} = ${param}; }