@groovy.transform.CompileStatic class PropertyDefinition extends AbstractMemberDefinition
Represents a property definition for domain class code generation. Properties in Groovy have no access modifier and auto-generate getter/setter methods.
| Modifiers | Name | Description |
|---|---|---|
static class |
PropertyDefinition.Builder |
Builder pattern for creating PropertyDefinition instances. |
| Properties inherited from class | Properties |
|---|---|
class AbstractMemberDefinition |
BUILTIN_TYPES, blank, constraintStyle, maxSize, minSize, name, nullable, type |
| Constructor and description |
|---|
PropertyDefinition() |
| Type Params | Return Type | Name and description |
|---|---|---|
|
static Builder |
builder()Factory for the PropertyDefinition.Builder. |
|
protected java.lang.String |
getMemberType() |
|
static PropertyDefinition |
parse(java.lang.String propertySpec)Parses a property specification string like "title:String" into a PropertyDefinition. |
|
java.lang.String |
toDeclaration()Generates the property declaration line for the domain class. |
| Methods inherited from class | Name |
|---|---|
class AbstractMemberDefinition |
getMemberType, getRequiredImports, isBuiltinType, isValidTypeName, toAnnotations, toConstraintLine, toDeclaration, usesGrailsConstraints, usesJakartaAnnotations, validate |
Factory for the PropertyDefinition.Builder. The return type is intentionally fully qualified:
FieldDefinition declares an inner Builder of the same simple name, and groovydoc resolves
unqualified Builder references inconsistently between builds (depends on filesystem iteration
order). Keep this qualified to ensure groovydoc renders PropertyDefinition.Builder reproducibly.
TODO(GROOVY-11954): Revisit and simplify the return type to Builder once Grails depends on
Groovy 4.0.32+ (also fixed in 5.0.6 and 6.0.0-alpha-1). The upstream fix corrects the shared
short-name resolution cache in SimpleGroovyClassDoc that causes this non-reproducibility,
so the workaround here will no longer be needed. As of writing, Grails pins groovy.version=4.0.31
and 4.0.32 has not yet been released to Maven Central. See:
https://issues.apache.org/jira/browse/GROOVY-11954 and https://github.com/apache/groovy/pull/2484.
Parses a property specification string like "title:String" into a PropertyDefinition.
propertySpec - the property specification (e.g., "title:String" or just "title")Generates the property declaration line for the domain class.