Comparator<GrImportStatement> (final GroovyCodeStyleSettings settings) { return (statement1, statement2) -> { if (settings.LAYOUT_STATIC_IMPORTS_SEPARATELY) { if (statement1.isStatic() && !statement2.isStatic()) return 1; if (statement2.isStatic() && !statement1.isStatic()) return -1; } String name1 = statement1.getImportFqn(); String name2 = statement2.getImportFqn(); if (name1 == null) return name2 == null ? 0 : -1; if (name2 == null) return 1; return name1.compareTo(name2); }; }