External services or interfaces that provide external services are often used in projects. In this case, return parameters must be escaped to avoid the impact of external objects on internal systems. For example, the interface datato getmydate () returns a value of datato. I need to convert it to our internal object datado. In this way, even if the datato provided by the business side changes, the impact on our internal system can be minimized. In this way, you need to write a conversion method from datato to datado, which is usually copying attributes, similar:
public static DataDO toDataDO(DataTO dataTO) { if (dataTO == null) { return null; } DataDO DataDO = new DataDO(); DataDO.setPlname(dataTO.getPlname()); DataDO.setPladdress(dataTO.getPladdress()); DataDO.setTel(dataTO.getTel()); DataDO.setUrl(dataTO.getUrl()); DataDO.setPosx(dataTO.getPosx()); DataDO.setPosy(dataTO.getPosy()); DataDO.setStoreType(dataTO.getStoreType()); return DataDO; }
You will find that if there are many attributes, you need to write a lot of such mechanical code, and sometimes you may miss one, it will be difficult to find the problem. At this time, someone will write a main function, and Java reflection can solve this problem well. If you want to develop idea plug-in, you want to develop a plug-in that can automatically generate the o2o method body.
There are not many idea plug-in documents on the Internet, and the Chinese language is also relatively old, but the basics are also compatible. References:
Http://www.intellij.org.cn/downloads/intellij_plugin_basic.pdf
Https://docs.google.com/document/pub? Id = 13wdycwgxerisfdptoxgu1mfuc1jezpjmyccazi2cepq
Http://confluence.jetbrains.com/display/IDEADEV/PluginDevelopment
The above are all Chinese, but the version is a little old. If you can use English, you can refer to the official documents.
Http://confluence.jetbrains.com/display/IDEADEV/PluginDevelopment
However, many APIs used later must be viewed in English documents. In actual development, there are still many pitfalls. learn more from the source code of other plug-ins and explore more.
The plug-in is now available
Source code: https://github.com/ykdsg/GenerateO2O