# Reorder Modifiers

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

# Tags

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

Use a Java Refactoring Tool

No license required

You can review this refactoring on your code without a license by installing jSparrow to your Eclipse IDE. Install the plug-in from Eclipse IDE: Eclipse Marketplace.

System-wide Refactoring

Do you want to automate this refactoring (and many more) to your system-wide code? The automatic application of this system-wide refactoring can be unlocked by acquiring your jSparrow license.

a drawn cute bird pointing at a graph that shows positive results

# Properties

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