Package org.openrewrite.gradle.trait
Class ExtraProperty
java.lang.Object
org.openrewrite.gradle.trait.ExtraProperty
- All Implemented Interfaces:
org.openrewrite.trait.Trait<org.openrewrite.java.tree.J>
public class ExtraProperty
extends Object
implements org.openrewrite.trait.Trait<org.openrewrite.java.tree.J>
Represents an extra property in a Gradle build script where the value is a string literal.
This trait only matches properties where the value can be statically determined as a string literal. Properties with variable references, expressions, or non-string values will not match and the trait will not be created for them.
Handles multiple syntax forms:
- Variable declarations:
def propertyName = 'value'orval propertyName = "value" - ext block assignments:
ext { propertyName = 'value' } - ext field access:
ext.propertyName = 'value' - ext.set() method:
ext.set("propertyName", "value") - ext subscript access:
ext['propertyName'] = 'value' - set() in ext block:
ext { set('propertyName', 'value') }
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic enumThe syntax form used to declare this property. -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.openrewrite.trait.Trait
getCursor, getTree
-
Constructor Details
-
ExtraProperty
public ExtraProperty()
-
-
Method Details
-
getName
-
getValue
Gets the string literal value of this property. This method always returns a non-null string because the trait is only created when a string literal value can be extracted from the source code.- Returns:
- The property's string literal value
-
withValue
Update the property value.- Parameters:
newValue- The new value to set- Returns:
- A new ExtraProperty with the updated value, or this if no change was made
-