如何检查Java类成员顺序

如何检查Java类成员顺序,java,coding-style,checkstyle,pmd,Java,Coding Style,Checkstyle,Pmd,我们正在使用PMD和Checkstyle(来自开发人员IDE和中央CI服务器)来检查代码是否符合我们的编码约定 我希望这些工具能提供一个检查类成员顺序的规则,但它们似乎没有 我所说的班级成员顺序是指: public static properties public properties protected properties private properties public constructors protected constructors private constructors

我们正在使用PMD和Checkstyle(来自开发人员IDE和中央CI服务器)来检查代码是否符合我们的编码约定

我希望这些工具能提供一个检查类成员顺序的规则,但它们似乎没有

我所说的班级成员顺序是指:

public static properties
public properties
protected properties
private properties

public constructors
protected constructors
private constructors

static methods

non-static methods
我当然可以写我自己的PMD规则,但我不习惯它,更不愿意重新发明轮子


你知道有什么工具可以为我们做这种检查吗?

Checkstyle实际上就是这样做的:

你可以使用Checkstyle的声明顺序检查

检查类或接口声明的部分是否显示在 Java编程的代码约定建议的顺序 语言

1.Class (static) variables. First the public class variables, 
然后是受保护的,然后是包级别(无访问修改器),然后是私有的

2.Instance variables. First the public class variables, then the protected,
3.Constructors

4.Methods
然后是包级别(无访问修改器),然后是私有

2.Instance variables. First the public class variables, then the protected,
3.Constructors

4.Methods

我建议大家,无论怎样,现代IDE都会按照这种顺序显示成员,有更好的东西值得关注。