Package org.openrewrite.java.style
Class CustomImportOrderStyle
java.lang.Object
org.openrewrite.java.style.CustomImportOrderStyle
- All Implemented Interfaces:
org.openrewrite.style.Style
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumstatic classRepresentation of a group, possibly with a parameter (depth for SAME_PACKAGE). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.openrewrite.style.StyleparseGroup(String groupRule) Parses a single import group rule, e.g., "STATIC", "SAME_PACKAGE(3)", "THIRD_PARTY_PACKAGE".parseImportOrder(String input) Parses a delimited string of import group rules into a list ofCustomImportOrderStyle.GroupWithDepthobjects.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.openrewrite.style.Style
getJacksonPolymorphicTypeTag, merge
-
Constructor Details
-
CustomImportOrderStyle
public CustomImportOrderStyle()
-
-
Method Details
-
applyDefaults
public org.openrewrite.style.Style applyDefaults()- Specified by:
applyDefaultsin interfaceorg.openrewrite.style.Style
-
parseGroup
Parses a single import group rule, e.g., "STATIC", "SAME_PACKAGE(3)", "THIRD_PARTY_PACKAGE". Throws IllegalArgumentException if the rule is not recognized.- Parameters:
groupRule- The input string representing a group rule. Example values: "STATIC", "SAME_PACKAGE(3)", "STANDARD_JAVA_PACKAGE", "SPECIAL_IMPORTS".- Returns:
- The corresponding
GroupWithDepthobject. - Throws:
IllegalArgumentException- if the input does not match a known group pattern.
-
parseImportOrder
Parses a delimited string of import group rules into a list ofCustomImportOrderStyle.GroupWithDepthobjects. Accepted delimiters are commas and "###", e.g., "STATIC, SAME_PACKAGE(3), ...".- Parameters:
input- Delimited rules string (e.g., "STATIC, SAME_PACKAGE(3), ...").- Returns:
- The list of parsed
GroupWithDepthobjects, or an empty list if input is null/blank.
-