# Reorder Modifiers

# Properties

Property Value
Rule ID ReorderModifiers
First seen in jSparrow version 3.6.0
Minimum Java version 1.1
Remediation cost 2 min
Links S1124

# 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.

# 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 {
    ...
} 

Automatic Application of This Rule

The automatic application of this rule is supported in the following jSparrow version:

# Tags

1
default
You & jSparrow
default

Hey there! May I help you? 😊