如何防止Java代码中的全限定名称 [英] How to prevent fully qualified names in Java code

查看:140
本文介绍了如何防止Java代码中的全限定名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用checkstyle检查Java项目是否在代码中使用了完全限定的名称。我们要避免使用

Is it possible to check with checkstyle if a java project is using fully qualified names in the code. We want to prevent code like

if (org.apache.commons.lang3.StringUtils.isBlank(name)) { 
 ....
 ....
} 

强制将软件包改为导入。

and want to enforce that packages are instead imported instead.

还有其他工具可以帮助我们实现它吗?

Are there are other tools that can help us accomplish it?

推荐答案

FTR我刚刚提出了 https://github.com/sevntu-checkstyle /sevntu.checkstyle/issues/462 关于可能在一段时间内将其添加到Checkstyle的问题。 ;-)

FTR I've just raised https://github.com/sevntu-checkstyle/sevntu.checkstyle/issues/462 about potentially adding this to Checkstyle some time .. contributions welcome! ;-)

这篇关于如何防止Java代码中的全限定名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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