Class DefaultImportOrderingStrategy
- java.lang.Object
-
- com.github.javaparser.printer.configuration.imports.DefaultImportOrderingStrategy
-
- All Implemented Interfaces:
ImportOrderingStrategy
public class DefaultImportOrderingStrategy extends Object implements ImportOrderingStrategy
-
-
Constructor Summary
Constructors Constructor Description DefaultImportOrderingStrategy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
isSortImportsAlphabetically()
void
setSortImportsAlphabetically(boolean sortImportsAlphabetically)
List<NodeList<ImportDeclaration>>
sortImports(NodeList<ImportDeclaration> nodes)
Sort the list of imports into groups.
-
-
-
Method Detail
-
sortImports
public List<NodeList<ImportDeclaration>> sortImports(NodeList<ImportDeclaration> nodes)
Description copied from interface:ImportOrderingStrategy
Sort the list of imports into groups.Consider that we have the following list of imports as argument:
import java.util.List; import com.github.javaparser.ast.NodeList; import com.github.javaparser.ast.ImportDeclaration;
And we want the imports to look like this: (Note the spacing between imports)
import java.util.List; import com.github.javaparser.ast.NodeList; import com.github.javaparser.ast.ImportDeclaration;
In this case, we have two groups of imports. The first group contains only import for java.util.List, while the second group contains NodeList and ImportDeclaration.
For this example this method should return 2 groups in the list, and the first group should have exactly 1 import, while the second group should have 2 imports.
- Specified by:
sortImports
in interfaceImportOrderingStrategy
- Parameters:
nodes
- The imports to be ordered.- Returns:
- The group of sorted imports.
-
setSortImportsAlphabetically
public void setSortImportsAlphabetically(boolean sortImportsAlphabetically)
- Specified by:
setSortImportsAlphabetically
in interfaceImportOrderingStrategy
-
isSortImportsAlphabetically
public boolean isSortImportsAlphabetically()
- Specified by:
isSortImportsAlphabetically
in interfaceImportOrderingStrategy
-
-