Class DeprecatedPropertyScanner.PropertyMigrationRule

  • All Implemented Interfaces:

    
    public final class DeprecatedPropertyScanner.PropertyMigrationRule
    
                        

    Data class representing a property migration rule with pattern matching.

    Used for runtime extensibility when explicit mappings are insufficient. Most migrations use explicit mappings in exactPropertyMappings for safety.

    PropertyMigrationRule(
        pattern = Pattern.compile("custom\\.company\\.(.+)"),
        replacement = "embabel.agent.custom.$1",
        description = "Custom company namespace migration"
    )
    • Constructor Detail

      • DeprecatedPropertyScanner.PropertyMigrationRule

        DeprecatedPropertyScanner.PropertyMigrationRule(Pattern pattern, String replacement, String description, Function1<String, Boolean> condition)
    • Method Detail

      • tryApply

         final String tryApply(String property)

        Attempts to transform a deprecated property name into its recommended replacement.

        IMPORTANT: This method performs string transformation only - it does NOT modify any files or source code. It's used purely for generating migration recommendations that will be shown in warnings.

        The transformation follows these steps:

        • Check optional condition (if present) - return null if condition fails

        • Apply regex pattern matching against the property name string

        • If pattern matches, perform string substitution using replacement template

        • Return the transformed property name string or null if no match

        val rule = PropertyMigrationRule(
            pattern = Pattern.compile("embabel\\.([^.]+)\\.max-attempts"),
            replacement = "embabel.agent.platform.models.$1.max-attempts"
        )
        
        val result = rule.tryApply("embabel.anthropic.max-attempts")
        // Returns: "embabel.agent.platform.models.anthropic.max-attempts"
        Parameters:
        property - The deprecated property name string to transform
        Returns:

        The recommended replacement property name string if rule applies, null otherwise