### Option Annotation Example Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/recipe-types-and-patterns.md Demonstrates the usage of the @Option annotation to mark constructor parameters as user-configurable options. ```java @Option( displayName = "Display name shown in UI", description = "Detailed explanation of this option", example = "example.value", required = false ) @Nullable private final String optionName; ``` -------------------------------- ### Preconditions Check Example Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/recipe-types-and-patterns.md Shows how to use Preconditions.check to define conditions that must be met before executing a visitor. Common preconditions include checking for type usage, method calls, or file patterns. ```java @Override public TreeVisitor getVisitor() { return Preconditions.check( new UsesType<>(FQN_CLASS, false), new MyVisitor() ); } ``` -------------------------------- ### MethodMatcher Examples Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/recipe-types-and-patterns.md Illustrates the usage of MethodMatcher for identifying specific method signatures, including constructors and methods with varargs. The second parameter controls whether to match overrides and supertypes. ```java new MethodMatcher("fully.qualified.ClassName methodName(param.Type1, param.Type2, ...)") ``` ```java // Constructor matching new MethodMatcher("fully.qualified.ClassName (param.Type)") ``` ```java // With varargs new MethodMatcher("fully.qualified.ClassName methodName(...)") ``` ```java new MethodMatcher("...", true) // Match overrides and supertypes ``` ```java new MethodMatcher("...", false) // Exact match only ``` -------------------------------- ### Recipe Equality and Hashing Implementation Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/recipe-types-and-patterns.md Implement equals() and hashCode() for recipes to ensure proper deduplication, caching, and comparison. This example shows a typical implementation comparing fields. ```java @Override public boolean equals(@Nullable Object o) { if (o == null || getClass() != o.getClass()) return false; if (!super.equals(o)) return false; MyRecipe that = (MyRecipe) o; return Objects.equals(field1, that.field1) && Objects.equals(field2, that.field2); } @Override public int hashCode() { return Objects.hash(super.hashCode(), field1, field2); } ``` -------------------------------- ### Example Usage of RenameSpringBootPropertyKey Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/spring-boot-properties-recipes.md Demonstrates how to instantiate and use the RenameSpringBootPropertyKey recipe to rename a property key in Spring Boot configuration files. ```java var recipe = new RenameSpringBootPropertyKey( "old.property.name", "new.property.name", true, null ); // Renames old.property.name to new.property.name in all Spring Boot config files ``` -------------------------------- ### TenantContextFilter Instantiation Before Builder Pattern Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/arconia-framework-recipes.md Example of how TenantContextFilter was instantiated using its constructor before the recipe transformation. ```java TenantContextFilter filter = new TenantContextFilter( tenantResolver, ignorePathMatcher, eventPublisher, tenantVerifier ); ``` -------------------------------- ### Configure Active Recipes via YAML Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/overview.md Example of configuring active recipes for Arconia Migrations using a YAML file. This specifies the recipe to be executed. ```yaml rewrite: activeRecipes: - io.arconia.rewrite.spring.boot.properties.ChangeSpringBootPropertyValue ``` -------------------------------- ### Example Usage of RenameSpringBootPropertyKeyIfValue Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/spring-boot-properties-recipes.md Shows how to use the RenameSpringBootPropertyKeyIfValue recipe to rename a property key only when its value matches a specific string. ```java var recipe = new RenameSpringBootPropertyKeyIfValue( "conventions.type", "langsmith", "conventions.opentelemetry.ai.flavor", true, null ); // Renames conventions.type to conventions.opentelemetry.ai.flavor // but only when the value is "langsmith" ``` -------------------------------- ### TenantContextFilter Instantiation After Builder Pattern Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/arconia-framework-recipes.md Example of TenantContextFilter instantiation using the builder pattern after applying the UseTenantContextFilterBuilder recipe. ```java TenantContextFilter filter = TenantContextFilter.builder() .httpRequestTenantResolver(tenantResolver) .tenantContextIgnorePathMatcher(ignorePathMatcher) .eventPublisher(eventPublisher) .tenantVerifier(tenantVerifier) .build(); ``` -------------------------------- ### Nullable Annotation Example Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/recipe-types-and-patterns.md Shows how to use the @Nullable annotation to indicate that a field can be null. ```java @Nullable private final String optionalField; ``` -------------------------------- ### JsonCreator Annotation Example Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/recipe-types-and-patterns.md Illustrates the @JsonCreator annotation, which Jackson uses to identify the constructor for deserialization. ```java @JsonCreator public SomeRecipe(String param1, String param2) { this.param1 = param1; this.param2 = param2; } ``` -------------------------------- ### ChangePropertyRecipe Example Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/recipe-types-and-patterns.md Demonstrates a ChangePropertyRecipe for modifying properties in Spring Boot configuration files. It identifies target files using path expressions and applies transformations to YAML and .properties formats. ```java public class ChangePropertyRecipe extends Recipe { @Option(displayName = "Property key", description = "...") private final String propertyKey; @Option(displayName = "...", description = "...", required = false) @Nullable private final List pathExpressions; @JsonCreator public ChangePropertyRecipe(String propertyKey, @Nullable List pathExpressions) { this.propertyKey = propertyKey; this.pathExpressions = pathExpressions; } @Override public TreeVisitor getVisitor() { return Preconditions.check( new FindSpringBootConfigFiles(pathExpressions).getVisitor(), new PropertyTransformingVisitor(propertyKey) ); } private static class PropertyTransformingVisitor extends TreeVisitor { @Override public @Nullable Tree visit(@Nullable Tree tree, ExecutionContext ctx) { if (tree == null) return null; return switch (tree) { case Yaml.Documents yamlTree -> transformYaml(yamlTree, ctx); case Properties.File propertiesTree -> transformProperties(propertiesTree, ctx); default -> tree; }; } } } ``` -------------------------------- ### Configure and Run Recipe with OpenRewrite Gradle Plugin Source: https://github.com/arconia-io/arconia-migrations/blob/main/docs/modules/ROOT/partials/run-recipe.adoc Set up the OpenRewrite Gradle plugin by creating an init.gradle file and then execute the recipe using Gradle. This method allows for specific module and recipe targeting. ```groovy initscript { repositories { gradlePluginPortal() } dependencies { classpath("org.openrewrite:plugin:latest.release") } } rootProject { plugins.apply(org.openrewrite.gradle.RewritePlugin) dependencies { rewrite("io.arconia.migrations:{rewrite-module}:latest.release") } // Remove when project repositories are disabled afterEvaluate { if (repositories.isEmpty()) { repositories { mavenCentral() } } } configurations.named("rewrite") { canBeConsumed = false } } ``` ```shell ./gradlew rewriteRun \ --init-script init.gradle \ --no-parallel \ -DactiveRecipe={recipe-id} ``` -------------------------------- ### MigrateSpringBoot3OtlpToArconiaOpenTelemetry Recipe Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/arconia-framework-recipes.md A migration recipe to automate the transition from Spring Boot's standard OTEL instrumentation to Arconia's OpenTelemetry integration. ```java io.arconia.rewrite.migration.MigrateSpringBoot3OtlpToArconiaOpenTelemetry ``` -------------------------------- ### MigrateSpringBoot4OtlpToArconiaOpenTelemetry Recipe Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/arconia-framework-recipes.md A migration recipe to automate the transition from Spring Boot's standard OTEL instrumentation to Arconia's OpenTelemetry integration. ```java io.arconia.rewrite.migration.MigrateSpringBoot4OtlpToArconiaOpenTelemetry ``` -------------------------------- ### UseGetPromptResultBuilder Recipe Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/spring-ai-recipes.md Recipe for modernizing GetPromptResult instantiation. ```java public class UseGetPromptResultBuilder extends Recipe ``` -------------------------------- ### Build and Test Locally Source: https://github.com/arconia-io/arconia-migrations/blob/main/CONTRIBUTING.md Build the project and run tests locally to ensure changes are functional. ```shell ./gradlew build ``` -------------------------------- ### UseTextContentBuilder Recipe Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/spring-ai-recipes.md Recipe for modernizing TextContent instantiation. ```java public class UseTextContentBuilder extends Recipe ``` -------------------------------- ### Arconia Migrations Project Structure Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/overview.md Illustrates the directory layout of the Arconia Migrations project, showing the organization of recipes for different frameworks. ```bash arconia-migrations/ ├── rewrite-arconia/ # Arconia framework recipes ├── rewrite-spring/ # Spring framework recipes ├── rewrite-test/ # Testing framework recipes ├── rewrite-docling/ # Docling library recipes └── rewrite-bom/ # Bill of materials ``` -------------------------------- ### getDescription() for RenameSpringBootPropertyKey Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/spring-boot-properties-recipes.md Returns the description for the RenameSpringBootPropertyKey recipe. ```java public String getDescription() ``` -------------------------------- ### Run Recipe with Arconia CLI Source: https://github.com/arconia-io/arconia-migrations/blob/main/docs/modules/ROOT/partials/run-recipe.adoc Use this command to apply a recipe via the Arconia CLI. Ensure the CLI command is correctly formatted. ```shell {cli-command} ``` -------------------------------- ### Java KafkaContainer Image Rewrite (String Literal) Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/testing-recipes.md Rewrites the image argument of a KafkaContainer constructor when the original image starts with a specific prefix. Use this to update image names in string literals. ```java new KafkaContainer("confluentinc/cp-kafka:7.0.0") ``` ```java new KafkaContainer("apache/kafka-native:7.0.0") ``` -------------------------------- ### Run Recipe with OpenRewrite Maven Plugin Source: https://github.com/arconia-io/arconia-migrations/blob/main/docs/modules/ROOT/partials/run-recipe.adoc Execute a recipe using the OpenRewrite Maven plugin. This command specifies the recipe artifact coordinates and the active recipe to be applied. ```shell ./mvnw -U org.openrewrite.maven:rewrite-maven-plugin:run \ -Drewrite.recipeArtifactCoordinates=io.arconia.migrations:{rewrite-module}:LATEST \ -Drewrite.activeRecipes={recipe-id} ``` -------------------------------- ### Use TenantContextFilterBuilder Recipe Class Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/arconia-framework-recipes.md This Java class defines a Rewrite recipe for modernizing TenantContextFilter instantiation. ```java public class UseTenantContextFilterBuilder extends Recipe ``` -------------------------------- ### Builder Pattern Transformation Recipe Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/recipe-types-and-patterns.md A recipe demonstrating the transformation from constructor-based instantiation to a builder pattern. It uses Preconditions.check and JavaTemplate for safe code generation. ```java public class UseBuilderPattern extends Recipe { private static final String FQN_TARGET_CLASS = "fully.qualified.ClassName"; private static final MethodMatcher CONSTRUCTOR_MATCHER = new MethodMatcher("fully.qualified.ClassName (param types)"); @Override public TreeVisitor getVisitor() { return Preconditions.check( new UsesMethod<>(CONSTRUCTOR_MATCHER), new JavaVisitor<>() { @Override public J visitNewClass(J.NewClass newClass, ExecutionContext ctx) { J.NewClass nc = (J.NewClass) super.visitNewClass(newClass, ctx); if (CONSTRUCTOR_MATCHER.matches(nc)) { List args = nc.getArguments(); maybeAddImport(FQN_TARGET_CLASS); return JavaTemplate.builder("ClassName.builder()...build()") .imports(FQN_TARGET_CLASS) .javaParser(JavaParser.fromJavaVersion()) .build() .apply(getCursor(), nc.getCoordinates().replace(), args); } return nc; } } ); } } ``` -------------------------------- ### GetDescription for UseQuestionAnswerAdvisorBuilder Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/spring-ai-recipes.md Provides the description for the UseQuestionAnswerAdvisorBuilder recipe. ```java public String getDescription() { return "Replace new QuestionAnswerAdvisor(...) with QuestionAnswerAdvisor.builder()....build()."; } ``` -------------------------------- ### Constructor for CommentSpringBootProperty Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/spring-boot-properties-recipes.md Defines the constructor for the CommentSpringBootProperty recipe, specifying the property key, the comment to add, and an option to comment out the property itself. ```java @JsonCreator public CommentSpringBootProperty( String propertyKey, String comment, @Nullable Boolean commentOutProperty ) ``` -------------------------------- ### UseProgressNotificationBuilder Recipe Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/spring-ai-recipes.md Recipe for modernizing ProgressNotification instantiation. ```java public class UseProgressNotificationBuilder extends Recipe ``` -------------------------------- ### Constructor for RenameSpringBootPropertyKeyIfValue Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/spring-boot-properties-recipes.md Defines the constructor for the RenameSpringBootPropertyKeyIfValue recipe, including parameters for the property key, its current value, the new key, relaxed binding, and path expressions. ```java @JsonCreator public RenameSpringBootPropertyKeyIfValue( String oldPropertyKey, String propertyValue, String newPropertyKey, @Nullable Boolean relaxedBinding, @Nullable List pathExpressions ) ``` -------------------------------- ### UseReadResourceResultBuilder Recipe Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/spring-ai-recipes.md Recipe for modernizing ReadResourceResult instantiation. ```java public class UseReadResourceResultBuilder extends Recipe ``` -------------------------------- ### Build a Class Instance Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/README.md Constructs a class instance using the builder pattern. This recipe is useful for creating complex objects with multiple optional parameters. ```java return JavaTemplate.builder("ClassName.builder()...build()") .imports(FQN) .javaParser(JavaParser.fromJavaVersion()) .build() .apply(getCursor(), nc.getCoordinates().replace(), args); ``` -------------------------------- ### Clone the Repository Source: https://github.com/arconia-io/arconia-migrations/blob/main/CONTRIBUTING.md Clone the Arconia Migrations repository to your local machine. ```shell git clone https://github.com//arconia-migrations.git cd arconia-migrations ``` -------------------------------- ### Basic JavaVisitor Implementation Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/recipe-types-and-patterns.md Extend JavaVisitor to implement AST transformations. Override methods like visitNewClass or visitMethodInvocation to modify specific code elements. This visitor shares cursor state between methods. ```java public class MyVisitor extends JavaVisitor { @Override public J visitNewClass(J.NewClass newClass, ExecutionContext ctx) { // Transform constructor calls return newClass; } @Override public J visitMethodInvocation(J.MethodInvocation method, ExecutionContext ctx) { // Transform method calls return method; } } ``` -------------------------------- ### Composing Recipes in YAML Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/api-index.md Demonstrates how to compose multiple recipes into a single recipe using a YAML definition. This is useful for creating complex workflows by combining simpler, pre-defined recipes. ```yaml recipeList: - io.arconia.rewrite.Recipe1 - io.arconia.rewrite.Recipe2: param: value ``` -------------------------------- ### Run Spring Framework 7.0 Upgrade Recipe Source: https://github.com/arconia-io/arconia-migrations/blob/main/docs/modules/ROOT/pages/spring/spring-framework/7-0.adoc Execute the Arconia recipe to automatically upgrade your project to Spring Framework 7.0.x. Ensure the 'rewrite-spring' module is configured. ```bash arconia rewrite run --recipe-name io.arconia.rewrite.spring.framework7.UpgradeSpringFramework_7_0 ``` -------------------------------- ### Constructor for RenameSpringBootPropertyKey Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/spring-boot-properties-recipes.md Defines the constructor for the RenameSpringBootPropertyKey recipe, specifying parameters for old and new property keys, relaxed binding, and path expressions. ```java public RenameSpringBootPropertyKey( String oldPropertyKey, String newPropertyKey, @Nullable Boolean relaxedBinding, @Nullable List pathExpressions ) ``` -------------------------------- ### GetDescription for UseToolResponseMessageBuilder Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/spring-ai-recipes.md Provides the description for the UseToolResponseMessageBuilder recipe. ```java public String getDescription() { return "Replace new ToolResponseMessage(...) with ToolResponseMessage.builder()....build()."; } ``` -------------------------------- ### UseToolResponseMessageBuilder Recipe Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/spring-ai-recipes.md Modernizes ToolResponseMessage instantiation by replacing direct constructor calls with the builder pattern. ```java public class UseToolResponseMessageBuilder extends Recipe ``` -------------------------------- ### getDescription() Method Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/arconia-framework-recipes.md Returns the description for the UseTenantContextFilterBuilder recipe. ```java public String getDescription() Returns: "Replace new TenantContextFilter(...) with TenantContextFilter.builder()....build()." ``` -------------------------------- ### UseQuestionAnswerAdvisorBuilder Recipe Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/spring-ai-recipes.md Replaces direct constructor calls of QuestionAnswerAdvisor with its builder pattern for improved readability and maintainability. ```java public class UseQuestionAnswerAdvisorBuilder extends Recipe ``` -------------------------------- ### getVisitor() Method Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/arconia-framework-recipes.md Returns a tree visitor that transforms constructor calls to builder patterns for TenantContextFilter. ```java public TreeVisitor getVisitor() ``` -------------------------------- ### UseOpenAiResponseFormatBuilder Recipe Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/spring-ai-recipes.md Modernizes OpenAI API response format configuration by replacing constructor calls with builder patterns for better code clarity and flexibility. ```java public class UseOpenAiResponseFormatBuilder extends Recipe ``` -------------------------------- ### Find Spring Boot Configuration Files Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/overview.md Recipe to locate Spring Boot configuration files (YAML and properties) using glob patterns. ```java FindSpringBootConfigFiles ``` -------------------------------- ### Run a Specific Arconia Migration Recipe Source: https://github.com/arconia-io/arconia-migrations/blob/main/docs/modules/ROOT/pages/index.adoc Execute a specific Arconia Migrations recipe using the Arconia CLI. This command targets the recipe for upgrading Spring Boot to version 4.0. ```shell arconia rewrite run --recipe-name io.arconia.rewrite.spring.boot4.UpgradeSpringBoot_4_0 ``` -------------------------------- ### Recipe Base Class Definition Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/recipe-types-and-patterns.md The abstract base class for all recipes, defining core methods for display name, description, and visitor logic. ```java public abstract class Recipe { public abstract String getDisplayName(); public abstract String getDescription(); public abstract TreeVisitor getVisitor(); } ``` -------------------------------- ### Arconia Version Migration Recipes Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/arconia-framework-recipes.md Lists Arconia version upgrade recipes, covering dependency upgrades, property migrations, and code transformations for versions 0.10.x through 0.28.x. ```java io.arconia.rewrite.UpgradeArconia_0_10 io.arconia.rewrite.UpgradeArconia_0_28 ``` -------------------------------- ### Use ConvertDocumentRequest Sources Method Recipe Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/arconia-framework-recipes.md This recipe replaces deprecated addHttpSources() and addFileSources() methods with the new source() method in Docling's ConvertDocumentRequest. It handles HTTP string URLs, HTTP URIs, and file sources. ```java public class UseConvertDocumentRequestSourcesMethod extends Recipe ``` ```java public String getDisplayName() { return "Use source() methods instead of addHttpSources() or addFileSources()"; } ``` ```java public String getDescription() { return "Replace .addHttpSources() or addFileSources() with .source(), wrapping arguments appropriately with HttpSource.builder() or FileSource.builder()."; } ``` ```java public TreeVisitor getVisitor() ``` ```java // Before ConvertDocumentRequest.builder() .addHttpSources("https://example.com/document.pdf") .build() // After ConvertDocumentRequest.builder() .source(HttpSource.builder().url(URI.create("https://example.com/document.pdf")).build()) .build() ``` ```java // Before URI documentUri = URI.create("https://example.com/document.pdf"); ConvertDocumentRequest.builder() .addHttpSources(documentUri) .build() // After URI documentUri = URI.create("https://example.com/document.pdf"); ConvertDocumentRequest.builder() .source(HttpSource.builder().url(documentUri).build()) .build() ``` ```java // Before ConvertDocumentRequest.builder() .addFileSources("document.pdf", "JVBERi0xLjQKJeLj...") .build() // After ConvertDocumentRequest.builder() .source(FileSource.builder().filename("document.pdf").base64String("JVBERi0xLjQKJeLj...").build()) .build() ``` -------------------------------- ### Execution Context Message Handling Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/recipe-types-and-patterns.md Illustrates how to interact with the ExecutionContext to retrieve or set messages and access the current transformation cycle. Common messages include `ExecutionContext.CURRENT_CYCLE`. ```java ctx.getMessage(key) // Get a message ``` ```java ctx.putMessage(key, value) // Set a message ``` ```java ctx.getCycle() // Get current transformation cycle ``` -------------------------------- ### Find Spring Boot Configuration Files Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/spring-boot-properties-recipes.md Finds Spring Boot configuration files based on provided path matchers. Use this to target specific configuration files for processing. ```java var recipe = new FindSpringBootConfigFiles( List.of("**/application.yml", "**/custom-config.yaml") ); // Finds all application.yml files and custom-config.yaml files ``` -------------------------------- ### Commit with Conventional Commits and DCO Source: https://github.com/arconia-io/arconia-migrations/blob/main/CONTRIBUTING.md Commit your changes using the Conventional Commits format and include a DCO sign-off. ```shell git commit -s -m "feat(spring): Add recipe for Spring Boot 4.1" ``` -------------------------------- ### OpenRewrite Test Class Pattern Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/recipe-types-and-patterns.md Standard pattern for testing OpenRewrite recipes. It initializes the recipe and uses the rewriteRun method with java() to assert transformations from input to expected output code. ```java public class MyRecipeTest { private final MyRecipe recipe = new MyRecipe(params); @Test void testTransformation() { rewriteRun( java( // Before "class Foo { ... }", // After "class Foo { ... }" ) ); } } ``` -------------------------------- ### getDisplayName() for RenameSpringBootPropertyKey Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/spring-boot-properties-recipes.md Returns the display name for the RenameSpringBootPropertyKey recipe. ```java public String getDisplayName() ``` -------------------------------- ### Migrate GetPromptResult to Builder Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/overview.md Applies the builder pattern to GetPromptResult in Spring AI MCP recipes. ```java UseGetPromptResultBuilder ``` -------------------------------- ### Find and Transform Spring Boot Configuration Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/README.md Applies transformations to Spring Boot configuration files. This recipe is used to find configuration files based on path expressions and apply specific transformations. ```java return Preconditions.check( new FindSpringBootConfigFiles(pathExpressions).getVisitor(), new ConfigTransformingVisitor(propertyKey, newValue) ); ``` -------------------------------- ### Import Management in Recipes Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/recipe-types-and-patterns.md Shows methods for managing import statements within recipes. `maybeAddImport` adds an import if not present, and `maybeRemoveImport` removes it if unused, handling duplicates and wildcard expansions. ```java maybeAddImport(FQN); // Add if not present ``` ```java maybeRemoveImport(FQN); // Remove if unused ``` -------------------------------- ### Transform Constructor to Builder Pattern Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/overview.md Converts a Java constructor with multiple arguments to a builder pattern. Ensure all fields have corresponding builder methods. ```java // Before new MyClass(arg1, arg2, arg3) // After MyClass.builder() .field1(arg1) .field2(arg2) .field3(arg3) .build() ``` -------------------------------- ### Use HealthCheckResponse Builder Recipe Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/arconia-framework-recipes.md This recipe modernizes HealthCheckResponse instantiation by replacing direct constructor calls with the builder pattern. It targets the HealthCheckResponse(String status) constructor. ```java public class UseHealthCheckResponseBuilder extends Recipe ``` ```java public String getDisplayName() { return "Use HealthCheckResponse.Builder instead of constructor"; } ``` ```java public String getDescription() { return "Replace new HealthCheckResponse(STATUS) with HealthCheckResponse.builder().status(status).build()."; } ``` ```java public TreeVisitor getVisitor() ``` ```java // Before HealthCheckResponse response = new HealthCheckResponse("ok"); ``` ```java // After HealthCheckResponse response = HealthCheckResponse.builder().status("ok").build(); ``` -------------------------------- ### Replace AssistantMessage constructor with builder Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/spring-ai-recipes.md This recipe modernizes `AssistantMessage` instantiation by replacing direct constructor calls with the builder pattern. It supports all constructor variants, ensuring compatibility with different argument combinations. ```java public class UseAssistantMessageBuilder extends Recipe ``` ```java public String getDisplayName() { return "Use AssistantMessage.Builder instead of constructor"; } ``` ```java public String getDescription() { return "Replace new AssistantMessage(...) with AssistantMessage.builder()....build()."; } ``` ```java public TreeVisitor getVisitor() ``` ```java // Before new AssistantMessage("Hello, world!") ``` ```java // After AssistantMessage.builder().content("Hello, world!").build() ``` ```java // Before new AssistantMessage("Response", properties) ``` ```java // After AssistantMessage.builder().content("Response").properties(properties).build() ``` ```java // Before new AssistantMessage("Response", properties, toolCalls) ``` ```java // After AssistantMessage.builder() .content("Response") .properties(properties) .toolCalls(toolCalls) .build() ``` ```java // Before new AssistantMessage("Response", properties, toolCalls, media) ``` ```java // After AssistantMessage.builder() .content("Response") .properties(properties) .toolCalls(toolCalls) .media(media) .build() ``` -------------------------------- ### Define a Nullable Option Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/README.md Defines a configuration option that can be null. Use this pattern when an option is optional and may not always have a value. ```java @Option(displayName = "Display Name", description = "Detailed description", example = "example-value", required = false) @Nullable private final String optionName; ``` -------------------------------- ### Create a New Branch Source: https://github.com/arconia-io/arconia-migrations/blob/main/CONTRIBUTING.md Create a new branch for your feature or fix, based on the main branch. ```shell git checkout -b my-feature-branch main ``` -------------------------------- ### Add Import and Return Transformed Node Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/recipe-types-and-patterns.md When transforming a node, you may need to add a corresponding import statement using maybeAddImport(FQN). Then, return the transformed node, potentially updating its type. ```java maybeAddImport(FQN); return transformedNode.withType(newType); ``` -------------------------------- ### Migrate QuestionAnswerAdvisor to Builder Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/overview.md Converts the constructor usage of QuestionAnswerAdvisor to its builder pattern in Spring AI projects. ```java UseQuestionAnswerAdvisorBuilder ``` -------------------------------- ### TenantContextFilter Constructor Signature Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/arconia-framework-recipes.md The targeted constructor for TenantContextFilter, which takes four parameters in a specific order. ```java TenantContextFilter( HttpRequestTenantResolver httpRequestTenantResolver, TenantContextIgnorePathMatcher tenantContextIgnorePathMatcher, ApplicationEventPublisher eventPublisher, TenantVerifier tenantVerifier ) ``` -------------------------------- ### Type Matching Utilities Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/recipe-types-and-patterns.md Provides utility methods for type matching and referencing in Java. Includes checks for exact class types, assignability, and extracting fully qualified names or generic parameters from types. ```java TypeUtils.isOfClassType(type, FQN) // Exact class type match ``` ```java TypeUtils.isAssignableTo(FQN, otherType) // Assignability check ``` ```java TypeUtils.asFullyQualified(type) // Extract FQN from type ``` ```java TypeUtils.asParameterized(type) // Extract generic parameters ``` -------------------------------- ### YAML Recipe Definition Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/recipe-types-and-patterns.md Define recipes using YAML for declarative composition. This format specifies the recipe's type, name, display name, description, tags, and a list of other recipes or parameterized recipes it includes. ```yaml --- type: specs.openrewrite.org/v1beta/recipe name: io.arconia.rewrite.RecipeName displayName: Human-Readable Recipe Name description: Detailed description of what this recipe does. tags: - tag1 - tag2 recipeList: - io.arconia.rewrite.OtherRecipe - org.openrewrite.SomeRecipe: param1: value1 param2: value2 ``` -------------------------------- ### Migrate TextContent to Builder Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/overview.md Applies the builder pattern to TextContent in Spring AI MCP recipes. ```java UseTextContentBuilder ``` -------------------------------- ### Chained Transformations in Visitor Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/recipe-types-and-patterns.md Perform sequential transformations by applying one transformation to the result of another. This pattern is useful for complex modifications requiring multiple steps. ```java var intermediate = transform1(node); var final = transform2(intermediate); return final; ``` -------------------------------- ### JavaTemplate Builder for Code Generation Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/recipe-types-and-patterns.md Demonstrates using JavaTemplate.builder for type-safe code generation with template syntax. It allows specifying imports and classpath for parsing Java code within templates. ```java JavaTemplate.builder("ClassName.builder().field(#{any()}).build()") .imports("fully.qualified.ClassName") .javaParser(JavaParser.fromJavaVersion() .classpathFromResources(ctx, "dependency-name")) .build() .apply(getCursor(), coordinates, arguments) ``` -------------------------------- ### GetDisplayName for UseQuestionAnswerAdvisorBuilder Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/spring-ai-recipes.md Provides the display name for the UseQuestionAnswerAdvisorBuilder recipe. ```java public String getDisplayName() { return "Use QuestionAnswerAdvisor.Builder instead of constructor"; } ``` -------------------------------- ### Standardize EmbeddingOptions builder instantiation Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/spring-ai-recipes.md This recipe updates references to use the correct class for builder instantiation. It replaces `EmbeddingOptionsBuilder.builder()` with `EmbeddingOptions.builder()` to align with changes in Spring AI 2.0. ```java public class UseEmbeddingOptionsBuilder extends Recipe ``` ```java public String getDisplayName() { return "Use EmbeddingOptions.builder() instead of EmbeddingOptionsBuilder.builder()"; } ``` ```java public String getDescription() { return "Replace EmbeddingOptionsBuilder.builder() with EmbeddingOptions.builder()."; } ``` ```java public TreeVisitor getVisitor() ``` -------------------------------- ### Migrate AssistantMessage to Builder Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/overview.md Converts the constructor usage of AssistantMessage to its builder pattern in Spring AI projects. ```java UseAssistantMessageBuilder ``` -------------------------------- ### Sign-off a New Commit Source: https://github.com/arconia-io/arconia-migrations/blob/main/CONTRIBUTING.md Add a DCO sign-off to a new commit. ```shell git commit -s -m "Your commit message" ``` -------------------------------- ### GetDisplayName for UseToolResponseMessageBuilder Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/spring-ai-recipes.md Provides the display name for the UseToolResponseMessageBuilder recipe. ```java public String getDisplayName() { return "Use ToolResponseMessage.Builder instead of constructor"; } ``` -------------------------------- ### Migrate EmbeddingOptionsBuilder to Builder Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/overview.md Updates Spring AI usage to prefer `EmbeddingOptions.builder()` over `EmbeddingOptionsBuilder.builder()`. ```java UseEmbeddingOptionsBuilder ``` -------------------------------- ### Migrate ProgressNotification to Builder Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/overview.md Applies the builder pattern to ProgressNotification in Spring AI MCP recipes. ```java UseProgressNotificationBuilder ``` -------------------------------- ### Remove .build() from ChatClient options Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/spring-ai-recipes.md Use this recipe to remove the `.build()` call from `ChatOptions` builder chains passed to `ChatClient.options()` and `ChatClient.Builder.defaultOptions()`. This is necessary as these methods accept `ChatOptions.Builder` directly in Spring AI 2.0. ```java public class UseChatOptionsBuilder extends Recipe ``` ```java public String getDisplayName() { return "Pass ChatOptions.Builder to ChatClient options methods"; } ``` ```java public String getDescription() { return "Remove .build() from ChatOptions builder chains passed to ChatClient.options() and ChatClient.Builder.defaultOptions(), as these methods now accept ChatOptions.Builder directly in Spring AI 2.0."; } ``` ```java public TreeVisitor getVisitor() ``` ```java chatClient.options(ChatOptions.builder() .temperature(0.5f) .build()) ``` ```java chatClient.options(ChatOptions.builder() .temperature(0.5f)) ``` -------------------------------- ### Migrate ToolResponseMessage to Builder Source: https://github.com/arconia-io/arconia-migrations/blob/main/_autodocs/overview.md Converts the constructor usage of ToolResponseMessage to its builder pattern in Spring AI projects. ```java UseToolResponseMessageBuilder ```