tryApply

fun tryApply(property: String): String?

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:

  1. Check optional condition (if present) - return null if condition fails

  2. Apply regex pattern matching against the property name string

  3. If pattern matches, perform string substitution using replacement template

  4. Return the transformed property name string or null if no match

Example Usage

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"

Return

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

Parameters

property

The deprecated property name string to transform