您可以将注释目标限制为某个类的子类吗? [英] Can you limit annotation target to be subclasses of a certain class?

查看:21
本文介绍了您可以将注释目标限制为某个类的子类吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您能否限制注释的目标必须属于某个类?

Can you limit that a target of an annotation must be of a certain class?

我想创建一个新的验证约束来限制上传的文件类型.约束注释必须只在 MultipartFile 属性上,而不是在 String 或类似的东西上.我该如何限制?

I want to create a new validation Constraint to limit file types that are uploaded. The constraint annotation must only go on a MultipartFile property, not on String or anything like that. How do I limit this?

推荐答案

不在编译时;注释放置的唯一限制是元素类型(方法、类等).

Not at compile-time; the only restrictions available for annotation placement are by element type (method, class, etc.).

这篇关于您可以将注释目标限制为某个类的子类吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆