Last week one of my friends teased Kotlin by saying that IDEA doesn’t support generating “high” serialized version numbers in Kotlin serialized classes. I tried it, but I didn’t support it! Since IDEA itself is not supported, there must be plug-in support. So, try a Google search and there is one, which was released in February and is still in alpha form. A quick install test did generate the serialized version number, but the generated value seemed to be a bit of a problem. And the plug-in only supports the Kotlin class, so it’s a shame that Java and Kotlin hybrid projects need to use two different ways to generate serialized version numbers. Well, if you don’t have one, develop one. It took a week of careful polishing. Today, I bring you a new serialization plug-in GenerateSerialVersionUID that supports both Kotlin and Java classes.

How to install

Method 1: Search the plugin market for installs (recommended)

The plugin is currently available on JetBrains’ Marketplace. You can search and download it in the IDEA Marketplace, but note that there are several plugins with the same name. Just select the one by Ouyangfeng and click the Install button.

Method 2: Download and install

Download address: plugins.jetbrains.com/plugin/1349…

If you open this link, you will find a list of current plugins. Please always download and install the latest version, and keep it up to date.

The update method is the same as that of updating IDEA. Click the menu Check Update.

After downloading, go to the Preferences menu ->Plugins, click the Settings icon in the upper right and select Install Plugin from Disk… Select the file you just downloaded.

Note: because the plug-in market server is in a foreign country, the first method may lead to slow installation. If you get stuck during the installation, you can use method 2 to install, or you can speed up the installation by small plane.

How to use

First, make sure your class implements the Serializable interface. Then leave the cursor in the body of the class, right click and select Generate->SerialVersionUID. If the serialVersionUID attribute already exists in the class but does not match the calculated value, it will be automatically updated. If the class does not exist, it will be automatically inserted. If the class declaration content changes, the property value can be updated in the same way, without manual update.

Operation demo diagram Click here to view: Gif operation demo diagram.

In addition, you can generate this property more quickly with shortcut keys. The default shortcut key combination is Ctrl + Shift + G.

compatibility

The plug-in can be used in IDEA or Android Studio 93.13 or later. Note That you need to view the corresponding IDEA version for Android Studio. 93.13 is an older version, which means that almost all of the current versions are supported and don’t have to worry about compatibility issues.

Report a problem

If you encounter any problems in the process of using it, please push an issue to me on Github, AND I will check and fix it as soon as possible.

To support me

If you find this plugin useful to you, please support me by clicking star in the Github source library of this plugin. You can also recommend this plugin to your friends. Thank you very much for using it!

Github source library address: github.com/yuanhoujun/…

Follow ouyang Feng Studio on wechat to read more technical articles.