Reorder Modifiers

Properties

Property Value
First seen in jSparrow version 3.6.0
Minimum Java version 1.1
Remediation cost 2 min
Links squid:ModifiersOrderCheck

Description

This rule reorders the modifiers on Type, Field and Method Declarations in the following priority:

  • public
  • protected
  • private
  • abstract
  • default
  • static
  • final
  • transient
  • volatile
  • synchronized
  • native
  • strictfp

Benefits

Improves the readability by unifying the order of modifiers in Type, Field and Method declarations.

Requirement & Tags

Requirements

None

Code Changes

Field Declarations

Pre

final static public String FINAL_STATIC_PUBLIC = "";  
static final public String STATIC_FINAL_PUBLIC = "";  
final public static String FINAL_PUBLIC_STATIC = "";  
public final static String PUBLIC_FINAL_STATIC = "";  
static public final String STATIC_PUBLIC_FINAL = "";  
public static final String PUBLIC_STATIC_FINAL = "";  

Post

public static final String FINAL_STATIC_PUBLIC = "";
public static final String STATIC_FINAL_PUBLIC = "";
public static final String FINAL_PUBLIC_STATIC = "";
public static final String PUBLIC_FINAL_STATIC = "";
public static final String STATIC_PUBLIC_FINAL = "";
public static final String PUBLIC_STATIC_FINAL = "";

Methods Declaration

Pre

static synchronized protected final void staticMethod() {
    ...
}

Post

protected static final synchronized void staticMethod() {
    ...
}

Type Declaration

Pre

static private class PrivateStaticClass {
    ...
} 

Post

private static class PrivateStaticClass {
    ...
}