Class CustomImportOrderStyle

java.lang.Object
org.openrewrite.java.style.CustomImportOrderStyle
All Implemented Interfaces:
org.openrewrite.style.Style

public class CustomImportOrderStyle extends Object implements org.openrewrite.style.Style
  • Constructor Details

    • CustomImportOrderStyle

      public CustomImportOrderStyle()
  • Method Details

    • applyDefaults

      public org.openrewrite.style.Style applyDefaults()
      Specified by:
      applyDefaults in interface org.openrewrite.style.Style
    • parseGroup

      public static CustomImportOrderStyle.GroupWithDepth parseGroup(String groupRule)
      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 GroupWithDepth object.
      Throws:
      IllegalArgumentException - if the input does not match a known group pattern.
    • parseImportOrder

      public static List<CustomImportOrderStyle.GroupWithDepth> parseImportOrder(String input)
      Parses a delimited string of import group rules into a list of CustomImportOrderStyle.GroupWithDepth objects. 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 GroupWithDepth objects, or an empty list if input is null/blank.