[英]java static factory methods in Spring Model class
Is it good to use java static factory method in Spring Model Class for validate field with some kind of equation Is it good to use java static factory method in Spring Model Class for validate field with some kind of equation
I would recommend to avoid this by the following reasons:我建议避免这种情况,原因如下:
What you can probably do is adding custom validation annotation to the model.您可能会做的是向 model 添加自定义验证注释。 This validation will be executed by spring bean that implements some spec.
此验证将由实现某些规范的 spring bean 执行。 This way you don't have above issues but still you can keep validation rule (without implementation details) on the model class.
这样您就没有上述问题,但您仍然可以在 model class 上保留验证规则(没有实现细节)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.