You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This rule would provide the "bean" part of BeanMembersShouldSerialize.
It would check, that the analyzed class adheres to the Java Beans Specification, that means:
Each field has a correctly named getter and setter
for indexed properties, check the field is an array and the types match
event listeners implement java.util.EventListener
event listeners always come in pairs (addXXListener, removeXXListener)
Firstly, I'd go for the approach of having to setup the rule with a required package to avoid the noisiness. The criteria for inference are too vague and would produce significant FPs / FNs.
I'd also have the check for serialization be optional through a property. Why? Because even though the actual usage of Java Beans as communication value objects has declined with JavaEE, the idea of an object with a default constructor with getters and setters has endured, and is used massively in other scenarios, such as:
Bean Validation (JSR 303 / 380), used standalone but also supported by Jersey, Spring and plenty of others.
JAXB
Jackson JSON library (when no annotations present)
Being able to enforce the compliance of these would be useful, as an error is mostly silent, with properties being dropped…
Proposed Rule Name: InvalidJavaBean
Proposed Category: Design
Description:
This rule would provide the "bean" part of BeanMembersShouldSerialize.
It would check, that the analyzed class adheres to the Java Beans Specification, that means:
java.util.EventListener
java.io.Serializable
- for the actually check, see the rule NonSerializableClass [java] Rename BeanMembersShouldSerialize to NonSerializableClass #4176)Care must be taken to make this rule not as noisy as #1668 . One strategy could be:
java.beans
Related issues:
References:
Code Sample:
Possible Properties:
package
- a regex to configure the packages where this rule should be applied toensureSerialization
- whether or not to check for java.io.SerializableThe text was updated successfully, but these errors were encountered: