NameStaticMethodsForStaticImport

Last edit August 28, 2009
One of the JavaIdioms.

When creating static methods in JavaLanguage 5 or greater, give consideration to how invoking the method read if the caller uses StaticImport.

Good names for static import:
  • java.util.EnumSet.allOf()
  • java.util.EnumSet.noneOf()
  • any of the org.junit.Assert methods
  • java.util.Arrays.asList
  • java.util.Collections.singletonList

Not so good:
  • java.util.EnumSet.of()
  • newInstance

On the other hand, if the combination of the class name and method name proves more meaningful, suggest that callers not statically import that particular method.