PMD規則之JavaBean Rules

來源:互聯網
上載者:User

·  BeanMembersShouldSerialize: If a class is a bean, or is referenced by a bean directly or indirectly it needs to be serializable. Member variables need to be marked as transient, static, or have accessor methods in the class. Marking variables as transient is the safest and easiest modification. Accessor methods should follow the Java naming conventions, i.e.if you have a variable foo, you should provide getFoo and setFoo methods.

翻譯  Bean成員應該是可序列化的:如果類是一個Java bean,或者被一個bean直接或間接地引用,它就需要序列化。類的成員變數需要被標記為transient,static,或具備存取方法。將變數標記為transient是最安全和最簡單的改動方法。存取方法應該遵循java命名規範,例如:如果有一個變數foo,應該提供getFoo()和setFoo()方法。

·  MissingSerialVersionUID: Classes that are serializable should provide a serialVersionUID field.

翻譯  缺少序列化版本ID:可序列化的類應該提供serialVersionUID域

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.